{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 329,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pymysql\n",
    "import pandas as pd\n",
    "import sklearn \n",
    "import numpy as np\n",
    "from sqlalchemy import create_engine\n",
    "import json\n",
    "import time\n",
    "engine = create_engine('mysql+pymysql://test:root123456!@localhost:3306/books_analysis')"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "各表对应内容注释\n",
    "用户操作事件表\n",
    "用户id 商品id 操作类型 操作时间\n",
    "\n",
    "用户表\tuserTable\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "用户ID\t性别\t年龄\t注册时间\t最后一次登录时间\t访问来源渠道\t\t\t\t\t\t\t\t\n",
    "userID\tsex\tage\trtime\tlltime\tchannel\t\t\t\t\t\t\t\t\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "物流表\toddTable\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "订单ID\t物流单号\t发货时间\t收货时间\t\t\t\t\t\t\t\t\t\t\n",
    "orderID\toddnumber\tdeliveryTime\treceiveTime\t\t\t\t\t\t\t\t\t\t\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "订单表\torderTable\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "订单ID\t订单时间\t买家ID\t商品ID\t买家IP\t收货地址\t手机号\t点击来源\t单点费用\t订单完成时间\t订单状态\t\t\t\n",
    "orderID\torderTime\tuserID\tcommodityID\tuserIP\tdeliveryAdress\tphonenumber\tclickSource\tpointFee\torderCompletionTime\torderActive\t\t\t\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "商品表                                                                                                              commodityTable\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "商品ID\t商品名称\t作者\t出版社\tIDBN编号\t分类\t定价\t商品售价\t月销量\t商品图片\t商品链接\t好评数\t差评数\t晒图数\n",
    "commodityID\tcommodityName\tauthor\tpress\tIDBN\tsort\tsetPrice\tsellPrice\tmonthlySales\tpicture\tlink\tpositive\tbad\tslideShow\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "访客表\tvisitorTable\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "访问IP\t访问时间\t二跳时间\t用户ID\t手机号\t商品ID\t访问链接\t访问事件\t来源渠道\t单点费用\t\t\t\t\n",
    "visitorIP\tvisitorTime\ttwoTime\tuserID\tphonenumber\tcommodityID\tvisitorLink\taccessEvents\tsourceChannel\tpointFee\t\t\t\t\n",
    "\t\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "退款表\trefundTable\t\t\t\t\t\t\t\t\t\t\t\t\n",
    "订单ID\t买家ID\t图书ID\t买家IP\t订单时间\t退款时间\t收货地址\t手机号\t是否有运费险\t退款原因\t\t\t\t\n",
    "orderID\tuserID\tcommodityID\tuserIP\torderTime\trefundTime\tdeliveryAddress\tphonenumber\tinsurance\treasonFrefund\t"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 340,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>tpye_operate</th>\n",
       "      <th>opreate_time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>0</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>2</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>2</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>0</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>0</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182875</th>\n",
       "      <td>847750</td>\n",
       "      <td>26631</td>\n",
       "      <td>0</td>\n",
       "      <td>20150730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182876</th>\n",
       "      <td>847750</td>\n",
       "      <td>26631</td>\n",
       "      <td>0</td>\n",
       "      <td>20150730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182877</th>\n",
       "      <td>847750</td>\n",
       "      <td>2845</td>\n",
       "      <td>0</td>\n",
       "      <td>20150812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182878</th>\n",
       "      <td>847750</td>\n",
       "      <td>5317</td>\n",
       "      <td>0</td>\n",
       "      <td>20150808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182879</th>\n",
       "      <td>847750</td>\n",
       "      <td>22353</td>\n",
       "      <td>0</td>\n",
       "      <td>20150808</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>182880 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         user_id  goods_id  tpye_operate  opreate_time\n",
       "0       10944750     13451             0      20150604\n",
       "1       10944750     13451             2      20150604\n",
       "2       10944750     13451             2      20150604\n",
       "3       10944750     13451             0      20150604\n",
       "4       10944750     13451             0      20150604\n",
       "...          ...       ...           ...           ...\n",
       "182875    847750     26631             0      20150730\n",
       "182876    847750     26631             0      20150730\n",
       "182877    847750      2845             0      20150812\n",
       "182878    847750      5317             0      20150808\n",
       "182879    847750     22353             0      20150808\n",
       "\n",
       "[182880 rows x 4 columns]"
      ]
     },
     "execution_count": 340,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "HOST = 'localhost'\n",
    "PORT = 3306\n",
    "USER = 'test'\n",
    "PASSWORD = 'root123456!'\n",
    "db = 'books_analysis'\n",
    "con = pymysql.connect(host=HOST,port=PORT,user=USER,password=PASSWORD,database=db)\n",
    "# 读取源表\n",
    "# 用户操作事件表\n",
    "#tpye_operate = 3 加入购物车\n",
    "#tpye_operate = 2 加入收藏\n",
    "#tpye_operate = 1 支付\n",
    "#tpye_operate = 0 浏览\n",
    "operate_df = pd.read_sql_query(\"select * from tb_data\",con)\n",
    "operate_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 221,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>goods_id</th>\n",
       "      <th>goods_name</th>\n",
       "      <th>author</th>\n",
       "      <th>publisher</th>\n",
       "      <th>IDBN</th>\n",
       "      <th>category</th>\n",
       "      <th>price</th>\n",
       "      <th>sell_price</th>\n",
       "      <th>sales_volume</th>\n",
       "      <th>img_url</th>\n",
       "      <th>goods_url</th>\n",
       "      <th>f_comments</th>\n",
       "      <th>n_comments</th>\n",
       "      <th>show_img</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>13451</td>\n",
       "      <td>人人都爱PS——中文版Photoshop CC技术教程（实例版）</td>\n",
       "      <td>唯美世界</td>\n",
       "      <td>水利水电出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>图形图像 多媒体</td>\n",
       "      <td>65.00</td>\n",
       "      <td>32.2</td>\n",
       "      <td>883</td>\n",
       "      <td>http://img3m2.ddimg.cn/3/15/25479732-1_w_7.jpg</td>\n",
       "      <td>http://product.dangdang.com/25479732.html</td>\n",
       "      <td>882</td>\n",
       "      <td>1</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>21110</td>\n",
       "      <td>终身机器学习（原书第2版）</td>\n",
       "      <td>陈志源</td>\n",
       "      <td>机械工业出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>计算机理论</td>\n",
       "      <td>79.00</td>\n",
       "      <td>59.2</td>\n",
       "      <td>232</td>\n",
       "      <td>http://img3m2.ddimg.cn/30/27/27914862-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/27914862.html</td>\n",
       "      <td>232</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1131</td>\n",
       "      <td>ANSYS Workbench18.0高阶应用与实例解析</td>\n",
       "      <td>买买提明·艾尼</td>\n",
       "      <td>机械工业出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>CAD CAM CAE</td>\n",
       "      <td>59.00</td>\n",
       "      <td>40.7</td>\n",
       "      <td>367</td>\n",
       "      <td>http://img3m5.ddimg.cn/10/0/25546465-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/25546465.html</td>\n",
       "      <td>367</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>8689</td>\n",
       "      <td>电脑世界的通关密语：电脑编程基础</td>\n",
       "      <td>杉浦贤</td>\n",
       "      <td>科学出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>45.00</td>\n",
       "      <td>33.7</td>\n",
       "      <td>361</td>\n",
       "      <td>http://img3m5.ddimg.cn/16/0/25258975-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/25258975.html</td>\n",
       "      <td>361</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>26619</td>\n",
       "      <td>复杂网络系统同步与控制</td>\n",
       "      <td>王健安</td>\n",
       "      <td>电子工业出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>网络与数据通信</td>\n",
       "      <td>69.00</td>\n",
       "      <td>47.6</td>\n",
       "      <td>0</td>\n",
       "      <td>http://img3m5.ddimg.cn/61/36/29124475-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/29124475.html</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9526</th>\n",
       "      <td>27123</td>\n",
       "      <td>知识的大苹果+小苹果丛书:机器人是人类最好的朋友吗</td>\n",
       "      <td>鲁道夫·格林</td>\n",
       "      <td>上海科学技术文献出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>百科知识</td>\n",
       "      <td>18.00</td>\n",
       "      <td>9.0</td>\n",
       "      <td>52</td>\n",
       "      <td>http://img3m4.ddimg.cn/4/19/24161944-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/24161944.html</td>\n",
       "      <td>52</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9527</th>\n",
       "      <td>27245</td>\n",
       "      <td>林中四季 一位博物学家的自然观察笔记【书籍正版 品质无忧 售后保障】</td>\n",
       "      <td>理查德·弗提</td>\n",
       "      <td>人民邮电出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>生物世界</td>\n",
       "      <td>366.60</td>\n",
       "      <td>58.6</td>\n",
       "      <td>0</td>\n",
       "      <td>http://img3m4.ddimg.cn/40/15/1758646534-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/1758646534.html</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9528</th>\n",
       "      <td>5742</td>\n",
       "      <td>博物学家的神秘动物图鉴 大幅手绘解剖图 还原神秘动物秘密妖怪书籍西方版的山海经异形演化 自然...</td>\n",
       "      <td>无</td>\n",
       "      <td>北京联合出版公司</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>生物世界</td>\n",
       "      <td>158.02</td>\n",
       "      <td>78.4</td>\n",
       "      <td>8</td>\n",
       "      <td>http://img3m7.ddimg.cn/27/33/1609912287-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/1609912287.html</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9529</th>\n",
       "      <td>2845</td>\n",
       "      <td>薛定谔的猫改变物理学的50个实验光学力学电磁学天文学书籍亚当哈特戴维斯著认知心理学心理学历史...</td>\n",
       "      <td>亚当·哈特</td>\n",
       "      <td>北京联合出版有限公司</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>百科知识</td>\n",
       "      <td>49.82</td>\n",
       "      <td>24.4</td>\n",
       "      <td>0</td>\n",
       "      <td>http://img3m7.ddimg.cn/18/25/1615458357-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/1615458357.html</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9530</th>\n",
       "      <td>5317</td>\n",
       "      <td>追光——光学的昨天和今天</td>\n",
       "      <td>雷仕湛</td>\n",
       "      <td>上海交通大学出版社</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>科学世界</td>\n",
       "      <td>39.80</td>\n",
       "      <td>31.4</td>\n",
       "      <td>96</td>\n",
       "      <td>http://img3m5.ddimg.cn/23/24/23351945-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/23351945.html</td>\n",
       "      <td>96</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>9531 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      goods_id                                         goods_name   author  \\\n",
       "0        13451                   人人都爱PS——中文版Photoshop CC技术教程（实例版）     唯美世界   \n",
       "1        21110                                      终身机器学习（原书第2版）      陈志源   \n",
       "2         1131                       ANSYS Workbench18.0高阶应用与实例解析  买买提明·艾尼   \n",
       "3         8689                                   电脑世界的通关密语：电脑编程基础      杉浦贤   \n",
       "4        26619                                        复杂网络系统同步与控制      王健安   \n",
       "...        ...                                                ...      ...   \n",
       "9526     27123                          知识的大苹果+小苹果丛书:机器人是人类最好的朋友吗   鲁道夫·格林   \n",
       "9527     27245                 林中四季 一位博物学家的自然观察笔记【书籍正版 品质无忧 售后保障】   理查德·弗提   \n",
       "9528      5742  博物学家的神秘动物图鉴 大幅手绘解剖图 还原神秘动物秘密妖怪书籍西方版的山海经异形演化 自然...        无   \n",
       "9529      2845  薛定谔的猫改变物理学的50个实验光学力学电磁学天文学书籍亚当哈特戴维斯著认知心理学心理学历史...    亚当·哈特   \n",
       "9530      5317                                       追光——光学的昨天和今天      雷仕湛   \n",
       "\n",
       "        publisher      IDBN     category   price  sell_price  sales_volume  \\\n",
       "0         水利水电出版社  9.79E+12     图形图像 多媒体   65.00        32.2           883   \n",
       "1         机械工业出版社  9.79E+12        计算机理论   79.00        59.2           232   \n",
       "2         机械工业出版社  9.79E+12  CAD CAM CAE   59.00        40.7           367   \n",
       "3           科学出版社  9.79E+12         程序设计   45.00        33.7           361   \n",
       "4         电子工业出版社  9.79E+12      网络与数据通信   69.00        47.6             0   \n",
       "...           ...       ...          ...     ...         ...           ...   \n",
       "9526  上海科学技术文献出版社  9.79E+12         百科知识   18.00         9.0            52   \n",
       "9527      人民邮电出版社  9.79E+12         生物世界  366.60        58.6             0   \n",
       "9528     北京联合出版公司  9.79E+12         生物世界  158.02        78.4             8   \n",
       "9529   北京联合出版有限公司  9.79E+12         百科知识   49.82        24.4             0   \n",
       "9530    上海交通大学出版社  9.79E+12         科学世界   39.80        31.4            96   \n",
       "\n",
       "                                                img_url  \\\n",
       "0        http://img3m2.ddimg.cn/3/15/25479732-1_w_7.jpg   \n",
       "1       http://img3m2.ddimg.cn/30/27/27914862-1_w_1.jpg   \n",
       "2        http://img3m5.ddimg.cn/10/0/25546465-1_w_3.jpg   \n",
       "3        http://img3m5.ddimg.cn/16/0/25258975-1_w_3.jpg   \n",
       "4       http://img3m5.ddimg.cn/61/36/29124475-1_w_2.jpg   \n",
       "...                                                 ...   \n",
       "9526     http://img3m4.ddimg.cn/4/19/24161944-1_w_2.jpg   \n",
       "9527  http://img3m4.ddimg.cn/40/15/1758646534-1_w_1.jpg   \n",
       "9528  http://img3m7.ddimg.cn/27/33/1609912287-1_w_1.jpg   \n",
       "9529  http://img3m7.ddimg.cn/18/25/1615458357-1_w_1.jpg   \n",
       "9530    http://img3m5.ddimg.cn/23/24/23351945-1_w_2.jpg   \n",
       "\n",
       "                                        goods_url  f_comments  n_comments  \\\n",
       "0       http://product.dangdang.com/25479732.html         882           1   \n",
       "1       http://product.dangdang.com/27914862.html         232           0   \n",
       "2       http://product.dangdang.com/25546465.html         367           0   \n",
       "3       http://product.dangdang.com/25258975.html         361           0   \n",
       "4       http://product.dangdang.com/29124475.html           0           0   \n",
       "...                                           ...         ...         ...   \n",
       "9526    http://product.dangdang.com/24161944.html          52           0   \n",
       "9527  http://product.dangdang.com/1758646534.html           0           0   \n",
       "9528  http://product.dangdang.com/1609912287.html           8           0   \n",
       "9529  http://product.dangdang.com/1615458357.html           0           0   \n",
       "9530    http://product.dangdang.com/23351945.html          96           0   \n",
       "\n",
       "      show_img  \n",
       "0            8  \n",
       "1            1  \n",
       "2            3  \n",
       "3            1  \n",
       "4            0  \n",
       "...        ...  \n",
       "9526         0  \n",
       "9527         0  \n",
       "9528         0  \n",
       "9529         0  \n",
       "9530         0  \n",
       "\n",
       "[9531 rows x 14 columns]"
      ]
     },
     "execution_count": 221,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 商品信息表\n",
    "goods_df = pd.read_sql_query(\"select * from tb_goods\",con)\n",
    "goods_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 222,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>logistics_num</th>\n",
       "      <th>delivery_time</th>\n",
       "      <th>receive_time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>234300087</td>\n",
       "      <td>609977000000</td>\n",
       "      <td>1.571535e+09</td>\n",
       "      <td>1.571788e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>251004020</td>\n",
       "      <td>26480943156</td>\n",
       "      <td>1.571440e+09</td>\n",
       "      <td>1.571814e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>534668639</td>\n",
       "      <td>539927000000</td>\n",
       "      <td>1.571499e+09</td>\n",
       "      <td>1.572006e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>477191863</td>\n",
       "      <td>145603000000</td>\n",
       "      <td>1.571499e+09</td>\n",
       "      <td>1.571725e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>290020591</td>\n",
       "      <td>506899000000</td>\n",
       "      <td>1.571457e+09</td>\n",
       "      <td>1.571783e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1322</th>\n",
       "      <td>368597466</td>\n",
       "      <td>None</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1323</th>\n",
       "      <td>238141027</td>\n",
       "      <td>None</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1324</th>\n",
       "      <td>629838444</td>\n",
       "      <td>None</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1325</th>\n",
       "      <td>443042375</td>\n",
       "      <td>None</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1326</th>\n",
       "      <td>356659141</td>\n",
       "      <td>None</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1327 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       order_id logistics_num  delivery_time  receive_time\n",
       "0     234300087  609977000000   1.571535e+09  1.571788e+09\n",
       "1     251004020   26480943156   1.571440e+09  1.571814e+09\n",
       "2     534668639  539927000000   1.571499e+09  1.572006e+09\n",
       "3     477191863  145603000000   1.571499e+09  1.571725e+09\n",
       "4     290020591  506899000000   1.571457e+09  1.571783e+09\n",
       "...         ...           ...            ...           ...\n",
       "1322  368597466          None            NaN           NaN\n",
       "1323  238141027          None            NaN           NaN\n",
       "1324  629838444          None            NaN           NaN\n",
       "1325  443042375          None            NaN           NaN\n",
       "1326  356659141          None            NaN           NaN\n",
       "\n",
       "[1327 rows x 4 columns]"
      ]
     },
     "execution_count": 222,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 物流表\n",
    "odd_df = pd.read_sql_query(\"select * from tb_odd\",con)\n",
    "odd_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 223,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>order_time</th>\n",
       "      <th>user_id</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>user_ip</th>\n",
       "      <th>receive_address</th>\n",
       "      <th>phone_num</th>\n",
       "      <th>click_source</th>\n",
       "      <th>point_fee</th>\n",
       "      <th>order_finish_time</th>\n",
       "      <th>order_active</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>206882668</td>\n",
       "      <td>1571367195</td>\n",
       "      <td>39750.0</td>\n",
       "      <td>15811</td>\n",
       "      <td>112.10.94.234</td>\n",
       "      <td>甘肃省 酒泉市 肃州区</td>\n",
       "      <td>1314092****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1571367277</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>172843092</td>\n",
       "      <td>1571354659</td>\n",
       "      <td>39750.0</td>\n",
       "      <td>17756</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>青海省 玉树藏族自治州 称多县</td>\n",
       "      <td>1318819****</td>\n",
       "      <td>直通车</td>\n",
       "      <td>1.9</td>\n",
       "      <td>1571354778</td>\n",
       "      <td>支付失败</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>222630628</td>\n",
       "      <td>1571407728</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>13779</td>\n",
       "      <td>115.28.26.13</td>\n",
       "      <td>河北省 邯郸市 磁县</td>\n",
       "      <td>1776498****</td>\n",
       "      <td>聚划算</td>\n",
       "      <td>1.5</td>\n",
       "      <td>1571407730</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>607322767</td>\n",
       "      <td>1571331697</td>\n",
       "      <td>64000.0</td>\n",
       "      <td>5814</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>河北省 秦皇岛市 海港区</td>\n",
       "      <td>1778203****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1571331761</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>578253185</td>\n",
       "      <td>1571390762</td>\n",
       "      <td>64000.0</td>\n",
       "      <td>2683</td>\n",
       "      <td>118.81.98.220</td>\n",
       "      <td>广西壮族自治区 南宁市 兴宁区</td>\n",
       "      <td>1895620****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1571390782</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1301</th>\n",
       "      <td>659694457</td>\n",
       "      <td>1571338508</td>\n",
       "      <td>NaN</td>\n",
       "      <td>527</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>黑龙江省 鸡西市 滴道区</td>\n",
       "      <td>1732140****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.6</td>\n",
       "      <td>1571338555</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1302</th>\n",
       "      <td>568016905</td>\n",
       "      <td>1571344172</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14902</td>\n",
       "      <td>123.158.68.87</td>\n",
       "      <td>江苏省 盐城市 东台市</td>\n",
       "      <td>1820800****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1571344224</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1303</th>\n",
       "      <td>545995769</td>\n",
       "      <td>1571338856</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6294</td>\n",
       "      <td>61.171.40.45</td>\n",
       "      <td>福建省 厦门市 翔安区</td>\n",
       "      <td>1717393****</td>\n",
       "      <td>直通车</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1571338860</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1304</th>\n",
       "      <td>485210876</td>\n",
       "      <td>1571352007</td>\n",
       "      <td>NaN</td>\n",
       "      <td>27985</td>\n",
       "      <td>121.41.117.242</td>\n",
       "      <td>宁夏回族自治区 银川市 金凤区</td>\n",
       "      <td>1735341****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.7</td>\n",
       "      <td>1571352022</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1305</th>\n",
       "      <td>280351013</td>\n",
       "      <td>1571336715</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16176</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>四川省 内江市 市中区</td>\n",
       "      <td>1518255****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.8</td>\n",
       "      <td>1571336736</td>\n",
       "      <td>支付成功</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1306 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       order_id  order_time  user_id  goods_id         user_ip  \\\n",
       "0     206882668  1571367195  39750.0     15811   112.10.94.234   \n",
       "1     172843092  1571354659  39750.0     17756  101.81.241.186   \n",
       "2     222630628  1571407728  42000.0     13779    115.28.26.13   \n",
       "3     607322767  1571331697  64000.0      5814  101.81.241.186   \n",
       "4     578253185  1571390762  64000.0      2683   118.81.98.220   \n",
       "...         ...         ...      ...       ...             ...   \n",
       "1301  659694457  1571338508      NaN       527  101.81.241.186   \n",
       "1302  568016905  1571344172      NaN     14902   123.158.68.87   \n",
       "1303  545995769  1571338856      NaN      6294    61.171.40.45   \n",
       "1304  485210876  1571352007      NaN     27985  121.41.117.242   \n",
       "1305  280351013  1571336715      NaN     16176  101.81.241.186   \n",
       "\n",
       "      receive_address    phone_num click_source  point_fee  order_finish_time  \\\n",
       "0         甘肃省 酒泉市 肃州区  1314092****         淘宝直播        1.4         1571367277   \n",
       "1     青海省 玉树藏族自治州 称多县  1318819****          直通车        1.9         1571354778   \n",
       "2          河北省 邯郸市 磁县  1776498****          聚划算        1.5         1571407730   \n",
       "3        河北省 秦皇岛市 海港区  1778203****         淘宝直播        1.4         1571331761   \n",
       "4     广西壮族自治区 南宁市 兴宁区  1895620****         淘宝直播        1.0         1571390782   \n",
       "...               ...          ...          ...        ...                ...   \n",
       "1301     黑龙江省 鸡西市 滴道区  1732140****         淘宝直播        1.6         1571338555   \n",
       "1302      江苏省 盐城市 东台市  1820800****         淘宝直播        0.8         1571344224   \n",
       "1303      福建省 厦门市 翔安区  1717393****          直通车        2.0         1571338860   \n",
       "1304  宁夏回族自治区 银川市 金凤区  1735341****         淘宝直播        0.7         1571352022   \n",
       "1305      四川省 内江市 市中区  1518255****         淘宝直播        1.8         1571336736   \n",
       "\n",
       "     order_active  \n",
       "0            支付成功  \n",
       "1            支付失败  \n",
       "2            支付成功  \n",
       "3            支付成功  \n",
       "4            支付成功  \n",
       "...           ...  \n",
       "1301         支付成功  \n",
       "1302         支付成功  \n",
       "1303         支付成功  \n",
       "1304         支付成功  \n",
       "1305         支付成功  \n",
       "\n",
       "[1306 rows x 11 columns]"
      ]
     },
     "execution_count": 223,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 订单表 \n",
    "order_df = pd.read_sql_query(\"select * from tb_order\",con)\n",
    "order_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 224,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>user_id</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>user_ip</th>\n",
       "      <th>order_time</th>\n",
       "      <th>refund_time</th>\n",
       "      <th>receive_address</th>\n",
       "      <th>phone_num</th>\n",
       "      <th>is_insurance</th>\n",
       "      <th>reason_frefund</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>234300087</td>\n",
       "      <td>11300000</td>\n",
       "      <td>24849</td>\n",
       "      <td>101.226.65.107</td>\n",
       "      <td>1571399151</td>\n",
       "      <td>1571887196</td>\n",
       "      <td>甘肃省 甘南藏族自治州 舟曲县</td>\n",
       "      <td>1503476****</td>\n",
       "      <td>是</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>251004020</td>\n",
       "      <td>11579750</td>\n",
       "      <td>22034</td>\n",
       "      <td>112.10.94.234</td>\n",
       "      <td>1571380580</td>\n",
       "      <td>1571878899</td>\n",
       "      <td>海南省 海口市 秀英区</td>\n",
       "      <td>1889979****</td>\n",
       "      <td>是</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>534668639</td>\n",
       "      <td>11701500</td>\n",
       "      <td>14065</td>\n",
       "      <td>121.41.112.148</td>\n",
       "      <td>1571390248</td>\n",
       "      <td>1571904877</td>\n",
       "      <td>内蒙古自治区 包头市 市辖区</td>\n",
       "      <td>1518028****</td>\n",
       "      <td>是</td>\n",
       "      <td>拍错/多拍</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>477191863</td>\n",
       "      <td>11751000</td>\n",
       "      <td>28803</td>\n",
       "      <td>114.247.56.183</td>\n",
       "      <td>1571336033</td>\n",
       "      <td>1571613911</td>\n",
       "      <td>辽宁省 铁岭市 清河区</td>\n",
       "      <td>1529163****</td>\n",
       "      <td>是</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>290020591</td>\n",
       "      <td>1579250</td>\n",
       "      <td>2197</td>\n",
       "      <td>112.10.94.234</td>\n",
       "      <td>1571369434</td>\n",
       "      <td>1571758553</td>\n",
       "      <td>上海市 市辖区 虹口区</td>\n",
       "      <td>1472485****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>227494287</td>\n",
       "      <td>6334000</td>\n",
       "      <td>20724</td>\n",
       "      <td>112.126.73.56</td>\n",
       "      <td>1571339870</td>\n",
       "      <td>1571844491</td>\n",
       "      <td>河北省 保定市 容城县</td>\n",
       "      <td>1337635****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>215983123</td>\n",
       "      <td>6497000</td>\n",
       "      <td>25177</td>\n",
       "      <td>115.28.26.13</td>\n",
       "      <td>1571394086</td>\n",
       "      <td>1571792497</td>\n",
       "      <td>北京市 市辖区 西城区</td>\n",
       "      <td>1352900****</td>\n",
       "      <td>是</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>217145120</td>\n",
       "      <td>6780500</td>\n",
       "      <td>7812</td>\n",
       "      <td>115.29.113.101</td>\n",
       "      <td>1571364244</td>\n",
       "      <td>1571627839</td>\n",
       "      <td>河南省 商丘市 宁陵县</td>\n",
       "      <td>1899943****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>679599972</td>\n",
       "      <td>8111500</td>\n",
       "      <td>1481</td>\n",
       "      <td>120.26.64.126</td>\n",
       "      <td>1571412293</td>\n",
       "      <td>1571849351</td>\n",
       "      <td>河北省 邢台市 临西县</td>\n",
       "      <td>1343423****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>383478643</td>\n",
       "      <td>9463750</td>\n",
       "      <td>949</td>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571377318</td>\n",
       "      <td>1571792912</td>\n",
       "      <td>西藏自治区 拉萨市 墨竹工卡县</td>\n",
       "      <td>1527379****</td>\n",
       "      <td>否</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>271 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      order_id   user_id  goods_id         user_ip  order_time  refund_time  \\\n",
       "0    234300087  11300000     24849  101.226.65.107  1571399151   1571887196   \n",
       "1    251004020  11579750     22034   112.10.94.234  1571380580   1571878899   \n",
       "2    534668639  11701500     14065  121.41.112.148  1571390248   1571904877   \n",
       "3    477191863  11751000     28803  114.247.56.183  1571336033   1571613911   \n",
       "4    290020591   1579250      2197   112.10.94.234  1571369434   1571758553   \n",
       "..         ...       ...       ...             ...         ...          ...   \n",
       "266  227494287   6334000     20724   112.126.73.56  1571339870   1571844491   \n",
       "267  215983123   6497000     25177    115.28.26.13  1571394086   1571792497   \n",
       "268  217145120   6780500      7812  115.29.113.101  1571364244   1571627839   \n",
       "269  679599972   8111500      1481   120.26.64.126  1571412293   1571849351   \n",
       "270  383478643   9463750       949   39.108.165.98  1571377318   1571792912   \n",
       "\n",
       "     receive_address    phone_num is_insurance reason_frefund  \n",
       "0    甘肃省 甘南藏族自治州 舟曲县  1503476****            是       收到商品破损污渍  \n",
       "1        海南省 海口市 秀英区  1889979****            是      材质与商品描述不符  \n",
       "2     内蒙古自治区 包头市 市辖区  1518028****            是          拍错/多拍  \n",
       "3        辽宁省 铁岭市 清河区  1529163****            是      材质与商品描述不符  \n",
       "4        上海市 市辖区 虹口区  1472485****            否      材质与商品描述不符  \n",
       "..               ...          ...          ...            ...  \n",
       "266      河北省 保定市 容城县  1337635****            否      材质与商品描述不符  \n",
       "267      北京市 市辖区 西城区  1352900****            是       收到商品破损污渍  \n",
       "268      河南省 商丘市 宁陵县  1899943****            否      材质与商品描述不符  \n",
       "269      河北省 邢台市 临西县  1343423****            否      材质与商品描述不符  \n",
       "270  西藏自治区 拉萨市 墨竹工卡县  1527379****            否       收到商品破损污渍  \n",
       "\n",
       "[271 rows x 10 columns]"
      ]
     },
     "execution_count": 224,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 退款表\n",
    "refund_df = pd.read_sql_query(\"select * from tb_refund\",con)\n",
    "refund_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 346,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>sex</th>\n",
       "      <th>age</th>\n",
       "      <th>register_time</th>\n",
       "      <th>last_login_time</th>\n",
       "      <th>source</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19500.0</td>\n",
       "      <td>女</td>\n",
       "      <td>30</td>\n",
       "      <td>1570512329</td>\n",
       "      <td>1571660943</td>\n",
       "      <td>淘宝社区</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>29750.0</td>\n",
       "      <td>未知</td>\n",
       "      <td>35</td>\n",
       "      <td>1570262740</td>\n",
       "      <td>1572137120</td>\n",
       "      <td>淘宝直播</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>38250.0</td>\n",
       "      <td>男</td>\n",
       "      <td>43</td>\n",
       "      <td>1569918447</td>\n",
       "      <td>1571510491</td>\n",
       "      <td>淘宝直播</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>39750.0</td>\n",
       "      <td>男</td>\n",
       "      <td>28</td>\n",
       "      <td>1570061806</td>\n",
       "      <td>0</td>\n",
       "      <td>淘宝搜索</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>42000.0</td>\n",
       "      <td>女</td>\n",
       "      <td>47</td>\n",
       "      <td>1570544668</td>\n",
       "      <td>0</td>\n",
       "      <td>聚划算</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1913</th>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>49</td>\n",
       "      <td>1570222856</td>\n",
       "      <td>1571587566</td>\n",
       "      <td>淘宝橱窗</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1914</th>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>34</td>\n",
       "      <td>1569985596</td>\n",
       "      <td>1572133118</td>\n",
       "      <td>淘宝直播</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1915</th>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>30</td>\n",
       "      <td>1570171105</td>\n",
       "      <td>1572109730</td>\n",
       "      <td>淘宝直播</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1916</th>\n",
       "      <td>NaN</td>\n",
       "      <td>女</td>\n",
       "      <td>29</td>\n",
       "      <td>1569938679</td>\n",
       "      <td>1572108333</td>\n",
       "      <td>淘宝直播</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1917</th>\n",
       "      <td>NaN</td>\n",
       "      <td>男</td>\n",
       "      <td>38</td>\n",
       "      <td>1570558775</td>\n",
       "      <td>1571727229</td>\n",
       "      <td>聚划算</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1918 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      user_id sex  age  register_time  last_login_time source\n",
       "0     19500.0   女   30     1570512329       1571660943   淘宝社区\n",
       "1     29750.0  未知   35     1570262740       1572137120   淘宝直播\n",
       "2     38250.0   男   43     1569918447       1571510491   淘宝直播\n",
       "3     39750.0   男   28     1570061806                0   淘宝搜索\n",
       "4     42000.0   女   47     1570544668                0    聚划算\n",
       "...       ...  ..  ...            ...              ...    ...\n",
       "1913      NaN   女   49     1570222856       1571587566   淘宝橱窗\n",
       "1914      NaN   女   34     1569985596       1572133118   淘宝直播\n",
       "1915      NaN   女   30     1570171105       1572109730   淘宝直播\n",
       "1916      NaN   女   29     1569938679       1572108333   淘宝直播\n",
       "1917      NaN   男   38     1570558775       1571727229    聚划算\n",
       "\n",
       "[1918 rows x 6 columns]"
      ]
     },
     "execution_count": 346,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 用户表\n",
    "user_df = pd.read_sql_query(\"select * from tb_user\",con)\n",
    "user_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 226,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>visitor_ip</th>\n",
       "      <th>visit_time</th>\n",
       "      <th>two_time</th>\n",
       "      <th>user_id</th>\n",
       "      <th>phone_num</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>visit_link</th>\n",
       "      <th>visit_events</th>\n",
       "      <th>source</th>\n",
       "      <th>point_fee</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>101.226.65.107</td>\n",
       "      <td>1571399151</td>\n",
       "      <td>1571399167</td>\n",
       "      <td>19500</td>\n",
       "      <td>1503476****</td>\n",
       "      <td>24849</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=532038730419***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>121.41.112.148</td>\n",
       "      <td>1571390248</td>\n",
       "      <td>1571390278</td>\n",
       "      <td>8666500</td>\n",
       "      <td>1518028****</td>\n",
       "      <td>14065</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=573659715732***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>114.247.56.183</td>\n",
       "      <td>1571336033</td>\n",
       "      <td>1571336067</td>\n",
       "      <td>267250</td>\n",
       "      <td>1529163****</td>\n",
       "      <td>28803</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=590428245179***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>171.118.180.243</td>\n",
       "      <td>1571407791</td>\n",
       "      <td>1571407812</td>\n",
       "      <td>11601500</td>\n",
       "      <td>1304833****</td>\n",
       "      <td>18289</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=17302099374****...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571353981</td>\n",
       "      <td>1571354011</td>\n",
       "      <td>8215250</td>\n",
       "      <td>1351254****</td>\n",
       "      <td>7692</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=601449111587***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>直通车</td>\n",
       "      <td>1.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5686</th>\n",
       "      <td>178.140.51.103</td>\n",
       "      <td>1571375258</td>\n",
       "      <td>1571375305</td>\n",
       "      <td>11646500</td>\n",
       "      <td>1755721****</td>\n",
       "      <td>9653</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=561027772418***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5687</th>\n",
       "      <td>120.27.47.33</td>\n",
       "      <td>1571341423</td>\n",
       "      <td>1571341493</td>\n",
       "      <td>981000</td>\n",
       "      <td>1841007****</td>\n",
       "      <td>4775</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=586454071825***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5688</th>\n",
       "      <td>65.208.151.115</td>\n",
       "      <td>1571354791</td>\n",
       "      <td>1571354804</td>\n",
       "      <td>2200750</td>\n",
       "      <td>1347045****</td>\n",
       "      <td>9846</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=570981208552***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>直通车</td>\n",
       "      <td>0.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5689</th>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571347900</td>\n",
       "      <td>1571347935</td>\n",
       "      <td>1449250</td>\n",
       "      <td>1368294****</td>\n",
       "      <td>13701</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=520237346984***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5690</th>\n",
       "      <td>112.126.73.56</td>\n",
       "      <td>1571328881</td>\n",
       "      <td>1571328892</td>\n",
       "      <td>239250</td>\n",
       "      <td>1553383****</td>\n",
       "      <td>10680</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=600528109589***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5691 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           visitor_ip  visit_time    two_time   user_id    phone_num  \\\n",
       "0      101.226.65.107  1571399151  1571399167     19500  1503476****   \n",
       "1      121.41.112.148  1571390248  1571390278   8666500  1518028****   \n",
       "2      114.247.56.183  1571336033  1571336067    267250  1529163****   \n",
       "3     171.118.180.243  1571407791  1571407812  11601500  1304833****   \n",
       "4       39.108.165.98  1571353981  1571354011   8215250  1351254****   \n",
       "...               ...         ...         ...       ...          ...   \n",
       "5686   178.140.51.103  1571375258  1571375305  11646500  1755721****   \n",
       "5687     120.27.47.33  1571341423  1571341493    981000  1841007****   \n",
       "5688   65.208.151.115  1571354791  1571354804   2200750  1347045****   \n",
       "5689    39.108.165.98  1571347900  1571347935   1449250  1368294****   \n",
       "5690    112.126.73.56  1571328881  1571328892    239250  1553383****   \n",
       "\n",
       "      goods_id                                         visit_link  \\\n",
       "0        24849  //detail.tmall.com/item.htm?id=532038730419***...   \n",
       "1        14065  //detail.tmall.com/item.htm?id=573659715732***...   \n",
       "2        28803  //detail.tmall.com/item.htm?id=590428245179***...   \n",
       "3        18289  //detail.tmall.com/item.htm?id=17302099374****...   \n",
       "4         7692  //detail.tmall.com/item.htm?id=601449111587***...   \n",
       "...        ...                                                ...   \n",
       "5686      9653  //detail.tmall.com/item.htm?id=561027772418***...   \n",
       "5687      4775  //detail.tmall.com/item.htm?id=586454071825***...   \n",
       "5688      9846  //detail.tmall.com/item.htm?id=570981208552***...   \n",
       "5689     13701  //detail.tmall.com/item.htm?id=520237346984***...   \n",
       "5690     10680  //detail.tmall.com/item.htm?id=600528109589***...   \n",
       "\n",
       "       visit_events source  point_fee  \n",
       "0     chargeRequest   淘宝直播        1.9  \n",
       "1     chargeRequest   淘宝直播        1.3  \n",
       "2     chargeRequest   淘宝直播        1.0  \n",
       "3     chargeRequest   淘宝直播        0.6  \n",
       "4     chargeRequest    直通车        1.4  \n",
       "...             ...    ...        ...  \n",
       "5686         launch   淘宝直播        1.9  \n",
       "5687         launch   淘宝直播        0.8  \n",
       "5688         launch    直通车        0.4  \n",
       "5689         launch   淘宝直播        0.7  \n",
       "5690         launch   淘宝直播        1.0  \n",
       "\n",
       "[5691 rows x 10 columns]"
      ]
     },
     "execution_count": 226,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 浏览事件表\n",
    "visit_df = pd.read_sql_query(\"select * from tb_visitor\",con)\n",
    "visit_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 227,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ip_start</th>\n",
       "      <th>ip_end</th>\n",
       "      <th>city</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0.0.0</td>\n",
       "      <td>0.255.255.255</td>\n",
       "      <td>IANA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.0.0.0</td>\n",
       "      <td>1.0.0.255</td>\n",
       "      <td>澳大利亚</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0.1.0</td>\n",
       "      <td>1.0.3.255</td>\n",
       "      <td>福建省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.0.4.0</td>\n",
       "      <td>1.0.7.255</td>\n",
       "      <td>澳大利亚</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.0.8.0</td>\n",
       "      <td>1.0.15.255</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446716</th>\n",
       "      <td>240.0.0.0</td>\n",
       "      <td>247.255.255.255</td>\n",
       "      <td>IANA保留地址</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446717</th>\n",
       "      <td>248.0.0.0</td>\n",
       "      <td>248.255.255.255</td>\n",
       "      <td>IANA保留地址</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446718</th>\n",
       "      <td>249.0.0.0</td>\n",
       "      <td>254.255.255.255</td>\n",
       "      <td>IANA保留地址</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446719</th>\n",
       "      <td>255.0.0.0</td>\n",
       "      <td>255.255.254.255</td>\n",
       "      <td>CZ88.NET</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446720</th>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>255.255.255.255</td>\n",
       "      <td>纯真网络</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>446721 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             ip_start           ip_end      city\n",
       "0             0.0.0.0    0.255.255.255      IANA\n",
       "1             1.0.0.0        1.0.0.255      澳大利亚\n",
       "2             1.0.1.0        1.0.3.255       福建省\n",
       "3             1.0.4.0        1.0.7.255      澳大利亚\n",
       "4             1.0.8.0       1.0.15.255       广东省\n",
       "...               ...              ...       ...\n",
       "446716      240.0.0.0  247.255.255.255  IANA保留地址\n",
       "446717      248.0.0.0  248.255.255.255  IANA保留地址\n",
       "446718      249.0.0.0  254.255.255.255  IANA保留地址\n",
       "446719      255.0.0.0  255.255.254.255  CZ88.NET\n",
       "446720  255.255.255.0  255.255.255.255      纯真网络\n",
       "\n",
       "[446721 rows x 3 columns]"
      ]
     },
     "execution_count": 227,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# ip地理位置表\n",
    "ip_df = pd.read_sql_query(\"select * from tb_ip\",con)\n",
    "ip_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>startip</th>\n",
       "      <th>stopip</th>\n",
       "      <th>code</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1851785216</td>\n",
       "      <td>1853882367</td>\n",
       "      <td>110000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2067791872</td>\n",
       "      <td>2069889023</td>\n",
       "      <td>110000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1858076672</td>\n",
       "      <td>1860173823</td>\n",
       "      <td>110000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>616562688</td>\n",
       "      <td>618659839</td>\n",
       "      <td>110000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>1870659584</td>\n",
       "      <td>1872756735</td>\n",
       "      <td>110000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2922</th>\n",
       "      <td>2923</td>\n",
       "      <td>3395379200</td>\n",
       "      <td>3395383295</td>\n",
       "      <td>810000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2923</th>\n",
       "      <td>2924</td>\n",
       "      <td>3395383296</td>\n",
       "      <td>3395387391</td>\n",
       "      <td>810000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2924</th>\n",
       "      <td>2925</td>\n",
       "      <td>3397595136</td>\n",
       "      <td>3397599231</td>\n",
       "      <td>810000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2925</th>\n",
       "      <td>2926</td>\n",
       "      <td>3418296320</td>\n",
       "      <td>3418300415</td>\n",
       "      <td>810000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2926</th>\n",
       "      <td>2927</td>\n",
       "      <td>3523350528</td>\n",
       "      <td>3523354623</td>\n",
       "      <td>810000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2927 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        id     startip      stopip    code\n",
       "0        1  1851785216  1853882367  110000\n",
       "1        2  2067791872  2069889023  110000\n",
       "2        3  1858076672  1860173823  110000\n",
       "3        4   616562688   618659839  110000\n",
       "4        5  1870659584  1872756735  110000\n",
       "...    ...         ...         ...     ...\n",
       "2922  2923  3395379200  3395383295  810000\n",
       "2923  2924  3395383296  3395387391  810000\n",
       "2924  2925  3397595136  3397599231  810000\n",
       "2925  2926  3418296320  3418300415  810000\n",
       "2926  2927  3523350528  3523354623  810000\n",
       "\n",
       "[2927 rows x 4 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# ip地理位置表\n",
    "# 将ip预处理为十进制范围的表   Code为省份对应的code\n",
    "ip_df = pd.read_sql_query(\"select * from c_ip_data\",con)\n",
    "ip_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 228,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>province</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>110000</td>\n",
       "      <td>北京市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>110101</td>\n",
       "      <td>北京市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>110102</td>\n",
       "      <td>北京市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>110105</td>\n",
       "      <td>北京市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>110106</td>\n",
       "      <td>北京市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3623</th>\n",
       "      <td>820000</td>\n",
       "      <td>澳门特别行政区</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3624</th>\n",
       "      <td>820101</td>\n",
       "      <td>澳门特别行政区</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3625</th>\n",
       "      <td>820102</td>\n",
       "      <td>澳门特别行政区</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3626</th>\n",
       "      <td>820103</td>\n",
       "      <td>澳门特别行政区</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3627</th>\n",
       "      <td>820104</td>\n",
       "      <td>澳门特别行政区</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3628 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        code province\n",
       "0     110000      北京市\n",
       "1     110101      北京市\n",
       "2     110102      北京市\n",
       "3     110105      北京市\n",
       "4     110106      北京市\n",
       "...      ...      ...\n",
       "3623  820000  澳门特别行政区\n",
       "3624  820101  澳门特别行政区\n",
       "3625  820102  澳门特别行政区\n",
       "3626  820103  澳门特别行政区\n",
       "3627  820104  澳门特别行政区\n",
       "\n",
       "[3628 rows x 2 columns]"
      ]
     },
     "execution_count": 228,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 省份code编号\n",
    "province_df = pd.read_sql_query(\"select * from city_code\",con)\n",
    "province_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 229,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>phone</th>\n",
       "      <th>province</th>\n",
       "      <th>city</th>\n",
       "      <th>mobile</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1300000</td>\n",
       "      <td>山东</td>\n",
       "      <td>济南</td>\n",
       "      <td>中国联通</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>1300001</td>\n",
       "      <td>江苏</td>\n",
       "      <td>常州</td>\n",
       "      <td>中国联通</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>1300002</td>\n",
       "      <td>安徽</td>\n",
       "      <td>巢湖</td>\n",
       "      <td>中国联通</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1300003</td>\n",
       "      <td>四川</td>\n",
       "      <td>宜宾</td>\n",
       "      <td>中国联通</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>1300004</td>\n",
       "      <td>四川</td>\n",
       "      <td>自贡</td>\n",
       "      <td>中国联通</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>360564</th>\n",
       "      <td>360565</td>\n",
       "      <td>1899995</td>\n",
       "      <td>新疆</td>\n",
       "      <td>乌鲁木齐</td>\n",
       "      <td>中国电信</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>360565</th>\n",
       "      <td>360566</td>\n",
       "      <td>1899996</td>\n",
       "      <td>新疆</td>\n",
       "      <td>乌鲁木齐</td>\n",
       "      <td>中国电信</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>360566</th>\n",
       "      <td>360567</td>\n",
       "      <td>1899997</td>\n",
       "      <td>新疆</td>\n",
       "      <td>乌鲁木齐</td>\n",
       "      <td>中国电信</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>360567</th>\n",
       "      <td>360568</td>\n",
       "      <td>1899998</td>\n",
       "      <td>新疆</td>\n",
       "      <td>乌鲁木齐</td>\n",
       "      <td>中国电信</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>360568</th>\n",
       "      <td>360569</td>\n",
       "      <td>1899999</td>\n",
       "      <td>新疆</td>\n",
       "      <td>乌鲁木齐</td>\n",
       "      <td>中国电信</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>360569 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            id    phone province  city mobile\n",
       "0            1  1300000       山东    济南   中国联通\n",
       "1            2  1300001       江苏    常州   中国联通\n",
       "2            3  1300002       安徽    巢湖   中国联通\n",
       "3            4  1300003       四川    宜宾   中国联通\n",
       "4            5  1300004       四川    自贡   中国联通\n",
       "...        ...      ...      ...   ...    ...\n",
       "360564  360565  1899995       新疆  乌鲁木齐   中国电信\n",
       "360565  360566  1899996       新疆  乌鲁木齐   中国电信\n",
       "360566  360567  1899997       新疆  乌鲁木齐   中国电信\n",
       "360567  360568  1899998       新疆  乌鲁木齐   中国电信\n",
       "360568  360569  1899999       新疆  乌鲁木齐   中国电信\n",
       "\n",
       "[360569 rows x 5 columns]"
      ]
     },
     "execution_count": 229,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 号码信息表\n",
    "phone_df = pd.read_sql_query(\"select * from tb_mobile\",con)\n",
    "phone_df"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "计算的指标分为以下几类：\n",
    "1.总体运营指标\n",
    "1.1流量类指标\n",
    "1.1.1PV（页面访问数） \n",
    "1.1.2UV（独立访客数）\n",
    "1.1.3人均页面访问数\n",
    "1.2订单产生效率指标\n",
    "1.2.1总订单数量\n",
    "1.2.2总访问数\n",
    "1.2.3访问到下单转化率\n",
    "1.3总体销售业绩指标\n",
    "1.3.1成交金额（包括未付款订单）\n",
    "1.3.2退款金额\n",
    "1.3.3销售金额（成功交易金额）\n",
    "1.3.4客单价（订单金额与订单数量之比）\n",
    "1.4整体指标\n",
    "1.4.1销售毛利(销售毛利=销售收入-成本（商品定价的40%))\n",
    "2.网站流量指标\n",
    "2.1流量成本类指标\n",
    "2.1.1访客获客成本(访客获客成本=广告或活动的投放费用/广告或活动带来的uv)\n",
    "2.2流量质量类指标\n",
    "2.2.1页面访问时长：单个页面被访问的时间\n",
    "3.销售转化指标\n",
    "3.1购物车类指标\n",
    "3.1.1购入购物车次数\n",
    "3.1.2加入购物车买家数\n",
    "3.1.3加入购物车商品数\n",
    "3.1.4购物车支付转化率(购物车支付转化率=加入购物车商品支付买家数/加入购物车的买家数)\n",
    "3.2下单类指标\n",
    "3.2.1下单笔数\n",
    "3.2.2下单金额\n",
    "3.2.3下单买家数\n",
    "3.2.4浏览下单转化率\n",
    "3.3支付类指标\n",
    "3.3.1支付金额\n",
    "3.3.2支付买家数\n",
    "3.3.3支付商品数\n",
    "3.3.4浏览-支付买家转换率\n",
    "3.3.5下单-支付金额转化率\n",
    "3.3.6下单-支付买家数转化率\n",
    "3.3.7下单-支付时长\n",
    "3.4交易类指标\n",
    "3.4.1交易成功订单数\n",
    "3.4.2交易成功金额\n",
    "3.4.3交易成功买家数\n",
    "3.4.4交易成功商品数\n",
    "3.4.5交易失败订单数\n",
    "3.4.6交易失败订单金额\n",
    "3.4.7交易失败订单买家数\n",
    "3.4.8交易失败商品数\n",
    "3.4.9退款总订单量\n",
    "3.4.10退款金额\n",
    "3.4.11退款率\n",
    "4.风控类指标\n",
    "4.1买家评价指标\n",
    "4.1.1买家评价上传图片数\n",
    "4.1.2买家评价数\n",
    "4.1.3买家好评率\n",
    "4.1.4买家差评率\n",
    "5.市场营销活动指标\n",
    "5.1广告投放指标\n",
    "5.1.1新增访客数\n",
    "5.1.2总访问次数\n",
    "5.1.3订单数量\n",
    "5.1.4UV订单转化率\n",
    "5.1.5广告投资回报率\n"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "=========================================\n",
    "总体运营指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 230,
   "metadata": {},
   "outputs": [],
   "source": [
    "#流量类指标  \n",
    "# PV（页面访问数） pageView 页面浏览\n",
    "PV = len(visit_df[visit_df['visit_events']=='pageView'])\n",
    "# UV（独立访客数）\n",
    "UV = len(visit_df['visitor_ip'].unique())\n",
    "# 人均页面访问数\n",
    "per_capita_page = round(PV/UV,2)\n",
    "# 订单产生效率指标\n",
    "# 总订单数量  chargeRequest 发起支付  \n",
    "total_order_quantity = len(visit_df[visit_df['visit_events']=='chargeRequest'])\n",
    "# 总访问数\n",
    "total_visit_num = len(visit_df[visit_df['visit_events']!='chargeRequest'])\n",
    "# 访问到下单转化率\n",
    "access_to_order_conversion_rate = total_order_quantity/total_visit_num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 231,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>order_time</th>\n",
       "      <th>user_id</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>user_ip</th>\n",
       "      <th>receive_address</th>\n",
       "      <th>phone_num</th>\n",
       "      <th>click_source</th>\n",
       "      <th>point_fee</th>\n",
       "      <th>order_finish_time</th>\n",
       "      <th>...</th>\n",
       "      <th>IDBN</th>\n",
       "      <th>category</th>\n",
       "      <th>price</th>\n",
       "      <th>sell_price</th>\n",
       "      <th>sales_volume</th>\n",
       "      <th>img_url</th>\n",
       "      <th>goods_url</th>\n",
       "      <th>f_comments</th>\n",
       "      <th>n_comments</th>\n",
       "      <th>show_img</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>206882668</td>\n",
       "      <td>1571367195</td>\n",
       "      <td>39750.0</td>\n",
       "      <td>15811</td>\n",
       "      <td>112.10.94.234</td>\n",
       "      <td>甘肃省 酒泉市 肃州区</td>\n",
       "      <td>1314092****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1571367277</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>计算机理论</td>\n",
       "      <td>59.0</td>\n",
       "      <td>40.7</td>\n",
       "      <td>1122</td>\n",
       "      <td>http://img3m3.ddimg.cn/98/27/22924043-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/22924043.html</td>\n",
       "      <td>1117</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>172843092</td>\n",
       "      <td>1571354659</td>\n",
       "      <td>39750.0</td>\n",
       "      <td>17756</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>青海省 玉树藏族自治州 称多县</td>\n",
       "      <td>1318819****</td>\n",
       "      <td>直通车</td>\n",
       "      <td>1.9</td>\n",
       "      <td>1571354778</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>79.0</td>\n",
       "      <td>39.5</td>\n",
       "      <td>16</td>\n",
       "      <td>http://img3m4.ddimg.cn/30/13/28972974-1_w_5.jpg</td>\n",
       "      <td>http://product.dangdang.com/28972974.html</td>\n",
       "      <td>16</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>222630628</td>\n",
       "      <td>1571407728</td>\n",
       "      <td>42000.0</td>\n",
       "      <td>13779</td>\n",
       "      <td>115.28.26.13</td>\n",
       "      <td>河北省 邯郸市 磁县</td>\n",
       "      <td>1776498****</td>\n",
       "      <td>聚划算</td>\n",
       "      <td>1.5</td>\n",
       "      <td>1571407730</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>网络与数据通信</td>\n",
       "      <td>69.0</td>\n",
       "      <td>48.6</td>\n",
       "      <td>422</td>\n",
       "      <td>http://img3m3.ddimg.cn/15/0/25200663-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/25200663.html</td>\n",
       "      <td>422</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>607322767</td>\n",
       "      <td>1571331697</td>\n",
       "      <td>64000.0</td>\n",
       "      <td>5814</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>河北省 秦皇岛市 海港区</td>\n",
       "      <td>1778203****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.4</td>\n",
       "      <td>1571331761</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>计算机理论</td>\n",
       "      <td>49.0</td>\n",
       "      <td>33.8</td>\n",
       "      <td>718</td>\n",
       "      <td>http://img3m6.ddimg.cn/91/6/9352126-1_w.jpg</td>\n",
       "      <td>http://product.dangdang.com/9352126.html</td>\n",
       "      <td>716</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>578253185</td>\n",
       "      <td>1571390762</td>\n",
       "      <td>64000.0</td>\n",
       "      <td>2683</td>\n",
       "      <td>118.81.98.220</td>\n",
       "      <td>广西壮族自治区 南宁市 兴宁区</td>\n",
       "      <td>1895620****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1571390782</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>家庭与办公室用书</td>\n",
       "      <td>59.0</td>\n",
       "      <td>45.6</td>\n",
       "      <td>1226</td>\n",
       "      <td>http://img3m4.ddimg.cn/7/7/23988994-1_w_6.jpg</td>\n",
       "      <td>http://product.dangdang.com/23988994.html</td>\n",
       "      <td>1225</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1301</th>\n",
       "      <td>659694457</td>\n",
       "      <td>1571338508</td>\n",
       "      <td>NaN</td>\n",
       "      <td>527</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>黑龙江省 鸡西市 滴道区</td>\n",
       "      <td>1732140****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.6</td>\n",
       "      <td>1571338555</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>79.0</td>\n",
       "      <td>55.2</td>\n",
       "      <td>56</td>\n",
       "      <td>http://img3m0.ddimg.cn/88/30/28539610-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/28539610.html</td>\n",
       "      <td>56</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1302</th>\n",
       "      <td>568016905</td>\n",
       "      <td>1571344172</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14902</td>\n",
       "      <td>123.158.68.87</td>\n",
       "      <td>江苏省 盐城市 东台市</td>\n",
       "      <td>1820800****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.8</td>\n",
       "      <td>1571344224</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>139.0</td>\n",
       "      <td>97.2</td>\n",
       "      <td>52</td>\n",
       "      <td>http://img3m6.ddimg.cn/68/7/26923316-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/26923316.html</td>\n",
       "      <td>52</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1303</th>\n",
       "      <td>545995769</td>\n",
       "      <td>1571338856</td>\n",
       "      <td>NaN</td>\n",
       "      <td>6294</td>\n",
       "      <td>61.171.40.45</td>\n",
       "      <td>福建省 厦门市 翔安区</td>\n",
       "      <td>1717393****</td>\n",
       "      <td>直通车</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1571338860</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>49.0</td>\n",
       "      <td>34.2</td>\n",
       "      <td>878</td>\n",
       "      <td>http://img3m9.ddimg.cn/36/30/22910319-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/22910319.html</td>\n",
       "      <td>875</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1304</th>\n",
       "      <td>485210876</td>\n",
       "      <td>1571352007</td>\n",
       "      <td>NaN</td>\n",
       "      <td>27985</td>\n",
       "      <td>121.41.117.242</td>\n",
       "      <td>宁夏回族自治区 银川市 金凤区</td>\n",
       "      <td>1735341****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.7</td>\n",
       "      <td>1571352022</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>49.0</td>\n",
       "      <td>34.5</td>\n",
       "      <td>917</td>\n",
       "      <td>http://img3m4.ddimg.cn/5/31/23740304-1_w_1.jpg</td>\n",
       "      <td>http://product.dangdang.com/23740304.html</td>\n",
       "      <td>915</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1305</th>\n",
       "      <td>280351013</td>\n",
       "      <td>1571336715</td>\n",
       "      <td>NaN</td>\n",
       "      <td>16176</td>\n",
       "      <td>101.81.241.186</td>\n",
       "      <td>四川省 内江市 市中区</td>\n",
       "      <td>1518255****</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.8</td>\n",
       "      <td>1571336736</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>数据库</td>\n",
       "      <td>79.0</td>\n",
       "      <td>53.0</td>\n",
       "      <td>913</td>\n",
       "      <td>http://img3m6.ddimg.cn/69/20/25260216-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/25260216.html</td>\n",
       "      <td>911</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1306 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       order_id  order_time  user_id  goods_id         user_ip  \\\n",
       "0     206882668  1571367195  39750.0     15811   112.10.94.234   \n",
       "1     172843092  1571354659  39750.0     17756  101.81.241.186   \n",
       "2     222630628  1571407728  42000.0     13779    115.28.26.13   \n",
       "3     607322767  1571331697  64000.0      5814  101.81.241.186   \n",
       "4     578253185  1571390762  64000.0      2683   118.81.98.220   \n",
       "...         ...         ...      ...       ...             ...   \n",
       "1301  659694457  1571338508      NaN       527  101.81.241.186   \n",
       "1302  568016905  1571344172      NaN     14902   123.158.68.87   \n",
       "1303  545995769  1571338856      NaN      6294    61.171.40.45   \n",
       "1304  485210876  1571352007      NaN     27985  121.41.117.242   \n",
       "1305  280351013  1571336715      NaN     16176  101.81.241.186   \n",
       "\n",
       "      receive_address    phone_num click_source  point_fee  order_finish_time  \\\n",
       "0         甘肃省 酒泉市 肃州区  1314092****         淘宝直播        1.4         1571367277   \n",
       "1     青海省 玉树藏族自治州 称多县  1318819****          直通车        1.9         1571354778   \n",
       "2          河北省 邯郸市 磁县  1776498****          聚划算        1.5         1571407730   \n",
       "3        河北省 秦皇岛市 海港区  1778203****         淘宝直播        1.4         1571331761   \n",
       "4     广西壮族自治区 南宁市 兴宁区  1895620****         淘宝直播        1.0         1571390782   \n",
       "...               ...          ...          ...        ...                ...   \n",
       "1301     黑龙江省 鸡西市 滴道区  1732140****         淘宝直播        1.6         1571338555   \n",
       "1302      江苏省 盐城市 东台市  1820800****         淘宝直播        0.8         1571344224   \n",
       "1303      福建省 厦门市 翔安区  1717393****          直通车        2.0         1571338860   \n",
       "1304  宁夏回族自治区 银川市 金凤区  1735341****         淘宝直播        0.7         1571352022   \n",
       "1305      四川省 内江市 市中区  1518255****         淘宝直播        1.8         1571336736   \n",
       "\n",
       "      ...      IDBN  category  price sell_price sales_volume  \\\n",
       "0     ...  9.79E+12     计算机理论   59.0       40.7         1122   \n",
       "1     ...  9.79E+12      程序设计   79.0       39.5           16   \n",
       "2     ...  9.79E+12   网络与数据通信   69.0       48.6          422   \n",
       "3     ...  9.79E+12     计算机理论   49.0       33.8          718   \n",
       "4     ...  9.79E+12  家庭与办公室用书   59.0       45.6         1226   \n",
       "...   ...       ...       ...    ...        ...          ...   \n",
       "1301  ...  9.79E+12      人工智能   79.0       55.2           56   \n",
       "1302  ...  9.79E+12      程序设计  139.0       97.2           52   \n",
       "1303  ...  9.79E+12      程序设计   49.0       34.2          878   \n",
       "1304  ...  9.79E+12      人工智能   49.0       34.5          917   \n",
       "1305  ...  9.79E+12       数据库   79.0       53.0          913   \n",
       "\n",
       "                                              img_url  \\\n",
       "0     http://img3m3.ddimg.cn/98/27/22924043-1_w_1.jpg   \n",
       "1     http://img3m4.ddimg.cn/30/13/28972974-1_w_5.jpg   \n",
       "2      http://img3m3.ddimg.cn/15/0/25200663-1_w_2.jpg   \n",
       "3         http://img3m6.ddimg.cn/91/6/9352126-1_w.jpg   \n",
       "4       http://img3m4.ddimg.cn/7/7/23988994-1_w_6.jpg   \n",
       "...                                               ...   \n",
       "1301  http://img3m0.ddimg.cn/88/30/28539610-1_w_1.jpg   \n",
       "1302   http://img3m6.ddimg.cn/68/7/26923316-1_w_3.jpg   \n",
       "1303  http://img3m9.ddimg.cn/36/30/22910319-1_w_1.jpg   \n",
       "1304   http://img3m4.ddimg.cn/5/31/23740304-1_w_1.jpg   \n",
       "1305  http://img3m6.ddimg.cn/69/20/25260216-1_w_3.jpg   \n",
       "\n",
       "                                      goods_url  f_comments  n_comments  \\\n",
       "0     http://product.dangdang.com/22924043.html        1117           1   \n",
       "1     http://product.dangdang.com/28972974.html          16           0   \n",
       "2     http://product.dangdang.com/25200663.html         422           0   \n",
       "3      http://product.dangdang.com/9352126.html         716           0   \n",
       "4     http://product.dangdang.com/23988994.html        1225           0   \n",
       "...                                         ...         ...         ...   \n",
       "1301  http://product.dangdang.com/28539610.html          56           0   \n",
       "1302  http://product.dangdang.com/26923316.html          52           0   \n",
       "1303  http://product.dangdang.com/22910319.html         875           1   \n",
       "1304  http://product.dangdang.com/23740304.html         915           0   \n",
       "1305  http://product.dangdang.com/25260216.html         911           1   \n",
       "\n",
       "     show_img  \n",
       "0           2  \n",
       "1           0  \n",
       "2           5  \n",
       "3           4  \n",
       "4           5  \n",
       "...       ...  \n",
       "1301        0  \n",
       "1302        1  \n",
       "1303        0  \n",
       "1304        1  \n",
       "1305        2  \n",
       "\n",
       "[1306 rows x 24 columns]"
      ]
     },
     "execution_count": 231,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 总体销售业绩指标\n",
    "# 拼接订单与商品df \n",
    "order_and_goods_df = order_df.merge(goods_df,left_on=['goods_id'],right_on=['goods_id'],how='left')\n",
    "order_and_goods_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 232,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "64842.34"
      ]
     },
     "execution_count": 232,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 成交金额（包括未付款订单）\n",
    "gvm = order_and_goods_df['sell_price'].sum()\n",
    "gvm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 233,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>order_id</th>\n",
       "      <th>user_id_x</th>\n",
       "      <th>goods_id_x</th>\n",
       "      <th>user_ip_x</th>\n",
       "      <th>order_time_x</th>\n",
       "      <th>refund_time</th>\n",
       "      <th>receive_address_x</th>\n",
       "      <th>phone_num_x</th>\n",
       "      <th>is_insurance</th>\n",
       "      <th>reason_frefund</th>\n",
       "      <th>...</th>\n",
       "      <th>IDBN</th>\n",
       "      <th>category</th>\n",
       "      <th>price</th>\n",
       "      <th>sell_price</th>\n",
       "      <th>sales_volume</th>\n",
       "      <th>img_url</th>\n",
       "      <th>goods_url</th>\n",
       "      <th>f_comments</th>\n",
       "      <th>n_comments</th>\n",
       "      <th>show_img</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>234300087</td>\n",
       "      <td>11300000</td>\n",
       "      <td>24849</td>\n",
       "      <td>101.226.65.107</td>\n",
       "      <td>1571399151</td>\n",
       "      <td>1571887196</td>\n",
       "      <td>甘肃省 甘南藏族自治州 舟曲县</td>\n",
       "      <td>1503476****</td>\n",
       "      <td>是</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>89.8</td>\n",
       "      <td>44.5</td>\n",
       "      <td>3256</td>\n",
       "      <td>http://img3m4.ddimg.cn/23/30/25108304-1_w_5.jpg</td>\n",
       "      <td>http://product.dangdang.com/25108304.html</td>\n",
       "      <td>3251</td>\n",
       "      <td>1</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>251004020</td>\n",
       "      <td>11579750</td>\n",
       "      <td>22034</td>\n",
       "      <td>112.10.94.234</td>\n",
       "      <td>1571380580</td>\n",
       "      <td>1571878899</td>\n",
       "      <td>海南省 海口市 秀英区</td>\n",
       "      <td>1889979****</td>\n",
       "      <td>是</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>89.0</td>\n",
       "      <td>39.6</td>\n",
       "      <td>1118</td>\n",
       "      <td>http://img3m8.ddimg.cn/94/19/25336768-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/25336768.html</td>\n",
       "      <td>1117</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>534668639</td>\n",
       "      <td>11701500</td>\n",
       "      <td>14065</td>\n",
       "      <td>121.41.112.148</td>\n",
       "      <td>1571390248</td>\n",
       "      <td>1571904877</td>\n",
       "      <td>内蒙古自治区 包头市 市辖区</td>\n",
       "      <td>1518028****</td>\n",
       "      <td>是</td>\n",
       "      <td>拍错/多拍</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>148.0</td>\n",
       "      <td>74.0</td>\n",
       "      <td>1659</td>\n",
       "      <td>http://img3m4.ddimg.cn/86/10/24080054-1_w_6.jpg</td>\n",
       "      <td>http://product.dangdang.com/24080054.html</td>\n",
       "      <td>1654</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>477191863</td>\n",
       "      <td>11751000</td>\n",
       "      <td>28803</td>\n",
       "      <td>114.247.56.183</td>\n",
       "      <td>1571336033</td>\n",
       "      <td>1571613911</td>\n",
       "      <td>辽宁省 铁岭市 清河区</td>\n",
       "      <td>1529163****</td>\n",
       "      <td>是</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>69.8</td>\n",
       "      <td>34.9</td>\n",
       "      <td>104</td>\n",
       "      <td>http://img3m6.ddimg.cn/33/29/28485996-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/28485996.html</td>\n",
       "      <td>102</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>290020591</td>\n",
       "      <td>1579250</td>\n",
       "      <td>2197</td>\n",
       "      <td>112.10.94.234</td>\n",
       "      <td>1571369434</td>\n",
       "      <td>1571758553</td>\n",
       "      <td>上海市 市辖区 虹口区</td>\n",
       "      <td>1472485****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>99.0</td>\n",
       "      <td>69.2</td>\n",
       "      <td>417</td>\n",
       "      <td>http://img3m5.ddimg.cn/64/23/25211305-1_w_4.jpg</td>\n",
       "      <td>http://product.dangdang.com/25211305.html</td>\n",
       "      <td>416</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>227494287</td>\n",
       "      <td>6334000</td>\n",
       "      <td>20724</td>\n",
       "      <td>112.126.73.56</td>\n",
       "      <td>1571339870</td>\n",
       "      <td>1571844491</td>\n",
       "      <td>河北省 保定市 容城县</td>\n",
       "      <td>1337635****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>79.0</td>\n",
       "      <td>37.9</td>\n",
       "      <td>23</td>\n",
       "      <td>http://img3m0.ddimg.cn/61/33/28544830-1_w_5.jpg</td>\n",
       "      <td>http://product.dangdang.com/28544830.html</td>\n",
       "      <td>23</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>215983123</td>\n",
       "      <td>6497000</td>\n",
       "      <td>25177</td>\n",
       "      <td>115.28.26.13</td>\n",
       "      <td>1571394086</td>\n",
       "      <td>1571792497</td>\n",
       "      <td>北京市 市辖区 西城区</td>\n",
       "      <td>1352900****</td>\n",
       "      <td>是</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>家庭与办公室用书</td>\n",
       "      <td>29.8</td>\n",
       "      <td>20.0</td>\n",
       "      <td>190</td>\n",
       "      <td>http://img3m4.ddimg.cn/62/6/25287434-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/25287434.html</td>\n",
       "      <td>190</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>217145120</td>\n",
       "      <td>6780500</td>\n",
       "      <td>7812</td>\n",
       "      <td>115.29.113.101</td>\n",
       "      <td>1571364244</td>\n",
       "      <td>1571627839</td>\n",
       "      <td>河南省 商丘市 宁陵县</td>\n",
       "      <td>1899943****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>...</td>\n",
       "      <td>1111111111</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>287.6</td>\n",
       "      <td>143.8</td>\n",
       "      <td>26</td>\n",
       "      <td>http://img3m5.ddimg.cn/59/25/410275265-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/410275265.html</td>\n",
       "      <td>26</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>679599972</td>\n",
       "      <td>8111500</td>\n",
       "      <td>1481</td>\n",
       "      <td>120.26.64.126</td>\n",
       "      <td>1571412293</td>\n",
       "      <td>1571849351</td>\n",
       "      <td>河北省 邢台市 临西县</td>\n",
       "      <td>1343423****</td>\n",
       "      <td>否</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>59.0</td>\n",
       "      <td>26.6</td>\n",
       "      <td>194</td>\n",
       "      <td>http://img3m6.ddimg.cn/52/0/27882016-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/27882016.html</td>\n",
       "      <td>193</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>383478643</td>\n",
       "      <td>9463750</td>\n",
       "      <td>949</td>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571377318</td>\n",
       "      <td>1571792912</td>\n",
       "      <td>西藏自治区 拉萨市 墨竹工卡县</td>\n",
       "      <td>1527379****</td>\n",
       "      <td>否</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "      <td>...</td>\n",
       "      <td>9.79E+12</td>\n",
       "      <td>图形图像 多媒体</td>\n",
       "      <td>89.9</td>\n",
       "      <td>42.7</td>\n",
       "      <td>106</td>\n",
       "      <td>http://img3m9.ddimg.cn/41/10/27921209-1_w_3.jpg</td>\n",
       "      <td>http://product.dangdang.com/27921209.html</td>\n",
       "      <td>105</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>271 rows × 33 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      order_id  user_id_x  goods_id_x       user_ip_x  order_time_x  \\\n",
       "0    234300087   11300000       24849  101.226.65.107    1571399151   \n",
       "1    251004020   11579750       22034   112.10.94.234    1571380580   \n",
       "2    534668639   11701500       14065  121.41.112.148    1571390248   \n",
       "3    477191863   11751000       28803  114.247.56.183    1571336033   \n",
       "4    290020591    1579250        2197   112.10.94.234    1571369434   \n",
       "..         ...        ...         ...             ...           ...   \n",
       "266  227494287    6334000       20724   112.126.73.56    1571339870   \n",
       "267  215983123    6497000       25177    115.28.26.13    1571394086   \n",
       "268  217145120    6780500        7812  115.29.113.101    1571364244   \n",
       "269  679599972    8111500        1481   120.26.64.126    1571412293   \n",
       "270  383478643    9463750         949   39.108.165.98    1571377318   \n",
       "\n",
       "     refund_time receive_address_x  phone_num_x is_insurance reason_frefund  \\\n",
       "0     1571887196   甘肃省 甘南藏族自治州 舟曲县  1503476****            是       收到商品破损污渍   \n",
       "1     1571878899       海南省 海口市 秀英区  1889979****            是      材质与商品描述不符   \n",
       "2     1571904877    内蒙古自治区 包头市 市辖区  1518028****            是          拍错/多拍   \n",
       "3     1571613911       辽宁省 铁岭市 清河区  1529163****            是      材质与商品描述不符   \n",
       "4     1571758553       上海市 市辖区 虹口区  1472485****            否      材质与商品描述不符   \n",
       "..           ...               ...          ...          ...            ...   \n",
       "266   1571844491       河北省 保定市 容城县  1337635****            否      材质与商品描述不符   \n",
       "267   1571792497       北京市 市辖区 西城区  1352900****            是       收到商品破损污渍   \n",
       "268   1571627839       河南省 商丘市 宁陵县  1899943****            否      材质与商品描述不符   \n",
       "269   1571849351       河北省 邢台市 临西县  1343423****            否      材质与商品描述不符   \n",
       "270   1571792912   西藏自治区 拉萨市 墨竹工卡县  1527379****            否       收到商品破损污渍   \n",
       "\n",
       "     ...        IDBN  category  price sell_price sales_volume  \\\n",
       "0    ...    9.79E+12      程序设计   89.8       44.5         3256   \n",
       "1    ...    9.79E+12      程序设计   89.0       39.6         1118   \n",
       "2    ...    9.79E+12      程序设计  148.0       74.0         1659   \n",
       "3    ...    9.79E+12      程序设计   69.8       34.9          104   \n",
       "4    ...    9.79E+12      程序设计   99.0       69.2          417   \n",
       "..   ...         ...       ...    ...        ...          ...   \n",
       "266  ...    9.79E+12      人工智能   79.0       37.9           23   \n",
       "267  ...    9.79E+12  家庭与办公室用书   29.8       20.0          190   \n",
       "268  ...  1111111111      程序设计  287.6      143.8           26   \n",
       "269  ...    9.79E+12      程序设计   59.0       26.6          194   \n",
       "270  ...    9.79E+12  图形图像 多媒体   89.9       42.7          106   \n",
       "\n",
       "                                              img_url  \\\n",
       "0     http://img3m4.ddimg.cn/23/30/25108304-1_w_5.jpg   \n",
       "1     http://img3m8.ddimg.cn/94/19/25336768-1_w_2.jpg   \n",
       "2     http://img3m4.ddimg.cn/86/10/24080054-1_w_6.jpg   \n",
       "3     http://img3m6.ddimg.cn/33/29/28485996-1_w_3.jpg   \n",
       "4     http://img3m5.ddimg.cn/64/23/25211305-1_w_4.jpg   \n",
       "..                                                ...   \n",
       "266   http://img3m0.ddimg.cn/61/33/28544830-1_w_5.jpg   \n",
       "267    http://img3m4.ddimg.cn/62/6/25287434-1_w_2.jpg   \n",
       "268  http://img3m5.ddimg.cn/59/25/410275265-1_w_3.jpg   \n",
       "269    http://img3m6.ddimg.cn/52/0/27882016-1_w_3.jpg   \n",
       "270   http://img3m9.ddimg.cn/41/10/27921209-1_w_3.jpg   \n",
       "\n",
       "                                      goods_url  f_comments  n_comments  \\\n",
       "0     http://product.dangdang.com/25108304.html        3251           1   \n",
       "1     http://product.dangdang.com/25336768.html        1117           0   \n",
       "2     http://product.dangdang.com/24080054.html        1654           3   \n",
       "3     http://product.dangdang.com/28485996.html         102           2   \n",
       "4     http://product.dangdang.com/25211305.html         416           0   \n",
       "..                                          ...         ...         ...   \n",
       "266   http://product.dangdang.com/28544830.html          23           0   \n",
       "267   http://product.dangdang.com/25287434.html         190           0   \n",
       "268  http://product.dangdang.com/410275265.html          26           0   \n",
       "269   http://product.dangdang.com/27882016.html         193           0   \n",
       "270   http://product.dangdang.com/27921209.html         105           0   \n",
       "\n",
       "    show_img  \n",
       "0         19  \n",
       "1          4  \n",
       "2          6  \n",
       "3          0  \n",
       "4          3  \n",
       "..       ...  \n",
       "266        0  \n",
       "267        2  \n",
       "268        0  \n",
       "269        0  \n",
       "270        1  \n",
       "\n",
       "[271 rows x 33 columns]"
      ]
     },
     "execution_count": 233,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 退款df与处理过的订单df合并\n",
    "refund_order = refund_df.merge(order_and_goods_df,left_on=['order_id'],right_on=['order_id'],how='left')\n",
    "refund_order"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 234,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.37053906444462054"
      ]
     },
     "execution_count": 234,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 退款金额\n",
    "refund_charge = refund_order['sell_price'].sum()\n",
    "refund_charge\n",
    "# 销售金额（成功交易金额）\n",
    "sales_amount = gvm - refund_charge\n",
    "# 客单价（订单金额与订单数量之比）\n",
    "unit_price_per_customer = gvm/len(order_and_goods_df)\n",
    "unit_price_per_customer\n",
    "# 整体指标\n",
    "# 销售毛利(销售毛利=销售收入-成本（商品定价的40%))\n",
    "sales_gross_profit = order_and_goods_df['sell_price'].sum() - order_and_goods_df['price'].sum()*0.4\n",
    "#毛利率\n",
    "gross_profit_margin = sales_gross_profit/gvm\n",
    "gross_profit_margin"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "========================================="
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "=========================================\n",
    "网站流量指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 235,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "42.50500790722193"
      ]
     },
     "execution_count": 235,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#流量成本类指标\n",
    "#访客获客成本=广告或活动的投放费用/广告或活动带来的uv cost_of_visitors \n",
    "cost_of_visitors = visit_df['point_fee'].sum()/UV\n",
    "#流量质量类指标\n",
    "#页面访问时长：单个页面被访问的时间，需与转化率结合分析 42.50500790722193\n",
    "#先计算各访问停留页面时长 residence_time\n",
    "visit_df['residence_time'] = visit_df['two_time'] - visit_df['visit_time']\n",
    "#页面平均访问时长 单位：s\n",
    "avg_visit_time = visit_df['residence_time'].mean()\n",
    "avg_visit_time"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "======================================"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "=========================================\n",
    "销售转化指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 236,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9583333333333334"
      ]
     },
     "execution_count": 236,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#购物车类指标：\n",
    "#购入购物车次数\n",
    "number_of_times_to_add_shopping_cart = len(operate_df[operate_df['tpye_operate']==3])\n",
    "#加入购物车买家数\n",
    "number_of_times_to_add_shopping_cart_buyers = len(operate_df[operate_df['tpye_operate']==3]['user_id'].unique())\n",
    "#加入购物车商品数\n",
    "number_of_items_added_to_shopping_cart = len(operate_df[operate_df['tpye_operate']==3]['goods_id'].unique())\n",
    "#购物车支付转化率=加入购物车商品支付买家数/加入购物车的买家数 \n",
    "#加入购物车并支付买家数\n",
    "cart_to_pay_the_number_of_buyers = len(operate_df[(operate_df['tpye_operate']==1) & (operate_df['user_id'].isin(operate_df[operate_df['tpye_operate']==3]['user_id']))]['user_id'].unique())\n",
    "cart_to_payment_rate = cart_to_pay_the_number_of_buyers / number_of_times_to_add_shopping_cart_buyers\n",
    "cart_to_payment_rate\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 237,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.47"
      ]
     },
     "execution_count": 237,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 下单类指标\n",
    "#下单笔数\n",
    "orders_num = len(order_df)\n",
    "#下单金额\n",
    "orders_amount = order_and_goods_df['sell_price'].sum()\n",
    "# 处理订单表user_id空值\n",
    "order_df.loc[order_df['user_id'].isnull(),'user_id'] = 0\n",
    "order_df['user_id'] = order_df['user_id'].astype(int)\n",
    "#下单买家数\n",
    "order_buyers = len(order_df[order_df['user_id']!=0]['user_id'].unique())\n",
    "#浏览下单转化率\n",
    "visit_to_order_rate = order_buyers/UV\n",
    "visit_to_order_rate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 238,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "62.06738131699847"
      ]
     },
     "execution_count": 238,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#支付类指标\n",
    "#支付金额\n",
    "payment_amount = order_and_goods_df[order_and_goods_df['order_active']=='支付成功']['sell_price'].sum()\n",
    "payment_amount\n",
    "#支付买家数\n",
    "payment_user_number = len(order_and_goods_df[order_and_goods_df['order_active']=='支付成功']['user_id'].unique())\n",
    "payment_user_number\n",
    "#支付商品数\n",
    "payment_goods_number = len(order_and_goods_df[order_and_goods_df['order_active']=='支付成功']['goods_id'])\n",
    "payment_goods_number\n",
    "#网站访客数\n",
    "website_visitors = len(visit_df[visit_df['visit_events']=='pageView']['user_id'].unique())\n",
    "website_visitors\n",
    "#浏览-支付买家转换率 = 支付买家数/网站访客数\n",
    "browse_pay_buyer_conversion_rate = payment_user_number/website_visitors\n",
    "browse_pay_buyer_conversion_rate\n",
    "#下单-支付金额转化率 = 支付金额/下单金额 :\n",
    "order_conversion_rate_of_payment_amount = payment_amount / orders_amount\n",
    "order_conversion_rate_of_payment_amount\n",
    "#下单-支付买家数转化率 = 支付买家数/下单买家数\n",
    "order_payment_buyer_number_conversion_rate = payment_user_number / order_buyers\n",
    "order_payment_buyer_number_conversion_rate\n",
    "#下单-支付时长 = 支付时间-下单时间\n",
    "# 计算每个订单从下单到支付的时间 生成新列 pay_to_finish\n",
    "order_and_goods_df['pay_to_finish'] = order_and_goods_df['order_finish_time'] - order_and_goods_df['order_time']\n",
    "#平均 下单-支付时长\n",
    "avg_pay_to_finish = order_and_goods_df['pay_to_finish'].mean()\n",
    "avg_pay_to_finish"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.20750382848392038"
      ]
     },
     "execution_count": 239,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#交易类指标\n",
    "#交易成功订单数\n",
    "number_of_successful_orders = len(order_and_goods_df[order_and_goods_df['order_active']=='支付成功']['order_id'])\n",
    "number_of_successful_orders\n",
    "#交易成功金额\n",
    "successful_transaction_amount = payment_amount\n",
    "number_of_successful_buyers = payment_user_number\n",
    "#交易成功商品数\n",
    "number_of_products_successfully_traded = len(order_and_goods_df[order_and_goods_df['order_active']=='支付成功']['goods_id'].unique())\n",
    "number_of_products_successfully_traded\n",
    "#交易失败订单数\n",
    "number_of_failed_orders = len(order_and_goods_df[order_and_goods_df['order_active']=='支付失败']['order_id'])\n",
    "number_of_failed_orders\n",
    "#交易失败订单金额\n",
    "failed_transaction_amount = order_and_goods_df[order_and_goods_df['order_active']=='支付失败']['sell_price'].sum()\n",
    "failed_transaction_amount\n",
    "#交易失败订单买家数\n",
    "number_of_buyers_of_failed_orders = len(order_and_goods_df[order_and_goods_df['order_active']=='支付失败']['user_id'].unique())\n",
    "#交易失败商品数\n",
    "number_of_products_failed_traded = len(order_and_goods_df[order_and_goods_df['order_active']=='支付失败']['goods_id'].unique())\n",
    "number_of_products_failed_traded\n",
    "#退款总订单量\n",
    "total_refund_order = len(refund_df)\n",
    "total_refund_order\n",
    "#退款金额 \n",
    "refund_amount = refund_order['sell_price'].sum()\n",
    "#退款率\n",
    "refund_rate = total_refund_order/len(order_df)\n",
    "refund_rate\n"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "============================="
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "==================================\n",
    "风控类指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 240,
   "metadata": {},
   "outputs": [],
   "source": [
    "#买家评价指标\n",
    "#买家评价上传图片数\n",
    "show_img_count = goods_df['show_img'].sum()\n",
    "show_img_count\n",
    "#买家评价数\n",
    "buyer_evaluation_number = goods_df['f_comments'].sum()+goods_df['n_comments'].sum()\n",
    "# 买家好评率\n",
    "f_comments_rate = goods_df['f_comments'].sum() / buyer_evaluation_number\n",
    "# 买家差评率\n",
    "n_comments_rate = goods_df['n_comments'].sum() / buyer_evaluation_number"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "=============================="
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "==================================\n",
    "市场营销活动指标"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 282,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "source\n",
       "淘宝搜索     60\n",
       "淘宝橱窗    115\n",
       "淘宝直播    231\n",
       "淘宝社区     96\n",
       "直通车     282\n",
       "聚划算     100\n",
       "Name: user_id, dtype: int64"
      ]
     },
     "execution_count": 282,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#广告投放指标\n",
    "temp_df = visit_df[['source','user_id']]\n",
    "#各源头新增访客df\n",
    "temp_df = temp_df.drop_duplicates(subset='user_id',keep='first')\n",
    "new_visitors_df = temp_df.groupby(['source'])['user_id'].count()\n",
    "new_visitors_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 242,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "884"
      ]
     },
     "execution_count": 242,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#新增访客数\n",
    "new_visitors = len(temp_df)\n",
    "new_visitors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 243,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5095"
      ]
     },
     "execution_count": 243,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#总访问次数\n",
    "total_visit_times = visit_df[visit_df['visit_events']!='chargeRequest']['visit_events'].count()\n",
    "total_visit_times"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 280,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "source\n",
       "淘宝搜索     45\n",
       "淘宝橱窗     68\n",
       "淘宝直播    149\n",
       "淘宝社区     70\n",
       "直通车     198\n",
       "聚划算      66\n",
       "Name: goods_id, dtype: int64"
      ]
     },
     "execution_count": 280,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#订单数量\n",
    "order_by_source = visit_df[visit_df['visit_events']=='chargeRequest'][['source','goods_id']].groupby(['source'])['goods_id'].count()\n",
    "order_by_source"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 245,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "596"
      ]
     },
     "execution_count": 245,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#订单数量\n",
    "order_by_source_nums = order_by_source.sum()\n",
    "order_by_source_nums"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 246,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.6742081447963801"
      ]
     },
     "execution_count": 246,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#UV订单转化率\n",
    "UV_order_rate = order_by_source_nums/new_visitors\n",
    "UV_order_rate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 247,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:5: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.\n",
      "  \"\"\"\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>point_fee</th>\n",
       "      <th>profit</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>source</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>淘宝搜索</th>\n",
       "      <td>400.4</td>\n",
       "      <td>16230.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>淘宝橱窗</th>\n",
       "      <td>755.5</td>\n",
       "      <td>32988.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>淘宝直播</th>\n",
       "      <td>1732.1</td>\n",
       "      <td>72516.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>淘宝社区</th>\n",
       "      <td>760.5</td>\n",
       "      <td>31175.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>直通车</th>\n",
       "      <td>2078.4</td>\n",
       "      <td>88432.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>聚划算</th>\n",
       "      <td>714.7</td>\n",
       "      <td>32782.80</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        point_fee    profit\n",
       "source                     \n",
       "淘宝搜索        400.4  16230.10\n",
       "淘宝橱窗        755.5  32988.70\n",
       "淘宝直播       1732.1  72516.30\n",
       "淘宝社区        760.5  31175.30\n",
       "直通车        2078.4  88432.06\n",
       "聚划算         714.7  32782.80"
      ]
     },
     "execution_count": 247,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#广告投资回报率\n",
    "visit_and_goods = visit_df.merge(goods_df,left_on=['goods_id'],right_on=['goods_id'],how='left')\n",
    "# 计算每个访问的利润 生成新列profit\n",
    "visit_and_goods['profit'] = visit_and_goods['sell_price'] - visit_and_goods['point_fee']\n",
    "visit_and_goods.groupby(['source'])['point_fee','profit'].sum()"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "=====================\n",
    "# 计算各省下单分布情况\n",
    "# 先将 ip范围表的省份code映射为中文\n",
    "ip_df = ip_df.merge(province_df,left_on=['code'],right_on=['code'],how='left')\n",
    "ip_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 248,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ip_start</th>\n",
       "      <th>ip_end</th>\n",
       "      <th>city</th>\n",
       "      <th>start</th>\n",
       "      <th>end</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.0.0.0</td>\n",
       "      <td>0.255.255.255</td>\n",
       "      <td>IANA</td>\n",
       "      <td>0</td>\n",
       "      <td>16646655</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1.0.0.0</td>\n",
       "      <td>1.0.0.255</td>\n",
       "      <td>澳大利亚</td>\n",
       "      <td>16581375</td>\n",
       "      <td>16581630</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0.1.0</td>\n",
       "      <td>1.0.3.255</td>\n",
       "      <td>福建省</td>\n",
       "      <td>16581630</td>\n",
       "      <td>16582395</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.0.4.0</td>\n",
       "      <td>1.0.7.255</td>\n",
       "      <td>澳大利亚</td>\n",
       "      <td>16582395</td>\n",
       "      <td>16583415</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.0.8.0</td>\n",
       "      <td>1.0.15.255</td>\n",
       "      <td>广东省</td>\n",
       "      <td>16583415</td>\n",
       "      <td>16585455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446716</th>\n",
       "      <td>240.0.0.0</td>\n",
       "      <td>247.255.255.255</td>\n",
       "      <td>IANA保留地址</td>\n",
       "      <td>3979530000</td>\n",
       "      <td>4112246280</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446717</th>\n",
       "      <td>248.0.0.0</td>\n",
       "      <td>248.255.255.255</td>\n",
       "      <td>IANA保留地址</td>\n",
       "      <td>4112181000</td>\n",
       "      <td>4128827655</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446718</th>\n",
       "      <td>249.0.0.0</td>\n",
       "      <td>254.255.255.255</td>\n",
       "      <td>IANA保留地址</td>\n",
       "      <td>4128762375</td>\n",
       "      <td>4228315905</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446719</th>\n",
       "      <td>255.0.0.0</td>\n",
       "      <td>255.255.254.255</td>\n",
       "      <td>CZ88.NET</td>\n",
       "      <td>4228250625</td>\n",
       "      <td>4244897025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>446720</th>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>255.255.255.255</td>\n",
       "      <td>纯真网络</td>\n",
       "      <td>4244897025</td>\n",
       "      <td>4244897280</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>446721 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             ip_start           ip_end      city       start         end\n",
       "0             0.0.0.0    0.255.255.255      IANA           0    16646655\n",
       "1             1.0.0.0        1.0.0.255      澳大利亚    16581375    16581630\n",
       "2             1.0.1.0        1.0.3.255       福建省    16581630    16582395\n",
       "3             1.0.4.0        1.0.7.255      澳大利亚    16582395    16583415\n",
       "4             1.0.8.0       1.0.15.255       广东省    16583415    16585455\n",
       "...               ...              ...       ...         ...         ...\n",
       "446716      240.0.0.0  247.255.255.255  IANA保留地址  3979530000  4112246280\n",
       "446717      248.0.0.0  248.255.255.255  IANA保留地址  4112181000  4128827655\n",
       "446718      249.0.0.0  254.255.255.255  IANA保留地址  4128762375  4228315905\n",
       "446719      255.0.0.0  255.255.254.255  CZ88.NET  4228250625  4244897025\n",
       "446720  255.255.255.0  255.255.255.255      纯真网络  4244897025  4244897280\n",
       "\n",
       "[446721 rows x 5 columns]"
      ]
     },
     "execution_count": 248,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 计算各省下单分布情况\n",
    "# ip_df 增加 各城市ip范围 两列 \n",
    "def trans(ip):\n",
    "    ips = ip.strip().split('.')\n",
    "    return int(ips[0])*255*255*255 + int(ips[1])*255*255 + int(ips[2])*255 + int(ips[3]) * 1\n",
    "ip_df['start'] = ip_df['ip_start'].apply(lambda x:trans(x))\n",
    "ip_df['end'] = ip_df['ip_end'].apply(lambda x:trans(x))\n",
    "ip_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 249,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "244986381\n",
      "2583    北京市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "3597460177\n",
      "253739    美国\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2046859776\n",
      "150404    北京市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "3379559847\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3042987551\n",
      "181419    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "2008669070\n",
      "144325    广东省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2334828865\n",
      "167957    上海市\n",
      "Name: city, dtype: object\n",
      "1876716247\n",
      "126481    北京市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1963899777\n",
      "137870    四川省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1877459172\n",
      "126585    湖北省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2903064265\n",
      "174932    吉林省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "668304535\n",
      "7668    美国\n",
      "Name: city, dtype: object\n",
      "2654111387\n",
      "171422    日本\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "242039524\n",
      "2527    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1689423148\n",
      "114432    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1091353197\n",
      "94806    美国\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "606625753\n",
      "6379    江苏省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "704261553\n",
      "8682    浙江省\n",
      "Name: city, dtype: object\n",
      "2334885508\n",
      "167973    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1758398861\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2006924522\n",
      "142875    广东省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1865209549\n",
      "124908    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2334899962\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3597460125\n",
      "253739    美国\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1582299552\n",
      "113146    俄罗斯\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2047654498\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1689431547\n",
      "114434    上海市\n",
      "Name: city, dtype: object\n",
      "2008669070\n",
      "144325    广东省\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "606625753\n",
      "6379    江苏省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "2008669070\n",
      "144325    广东省\n",
      "Name: city, dtype: object\n",
      "3379559831\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2008669070\n",
      "144325    广东省\n",
      "Name: city, dtype: object\n",
      "2049972229\n",
      "151600    河南省\n",
      "Name: city, dtype: object\n",
      "3198418708\n",
      "191285    美国\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1991530988\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1995755606\n",
      "142158    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "3435339119\n",
      "234007    美国\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "3379559868\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "2334899961\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1982272672\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "3677291048\n",
      "393060    天津市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "3677855724\n",
      "396283    山西省\n",
      "Name: city, dtype: object\n",
      "1876716247\n",
      "126481    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3379559868\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "2038288511\n",
      "148548    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "2334885508\n",
      "167973    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2776558361\n",
      "173208    美国\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "2047654557\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "2008669070\n",
      "144325    广东省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1689423164\n",
      "114432    上海市\n",
      "Name: city, dtype: object\n",
      "3050021234\n",
      "182443    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2334899959\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "668304535\n",
      "7668    美国\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2048510337\n",
      "151145    陕西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2334899957\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1091353195\n",
      "94806    美国\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "3379559844\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1995755637\n",
      "142158    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1876716247\n",
      "126481    北京市\n",
      "Name: city, dtype: object\n",
      "1952057498\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "3301650586\n",
      "211172    美国\n",
      "Name: city, dtype: object\n",
      "2334899961\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1982272672\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1689431547\n",
      "114434    上海市\n",
      "Name: city, dtype: object\n",
      "1091353198\n",
      "94806    美国\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1689431547\n",
      "114434    上海市\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1904320912\n",
      "129591    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "606625753\n",
      "6379    江苏省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3677291048\n",
      "393060    天津市\n",
      "Name: city, dtype: object\n",
      "3023830497\n",
      "179062    北京市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "3379559829\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "3379559831\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "2334899959\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "3435339119\n",
      "234007    美国\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1995755637\n",
      "142158    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "706596393\n",
      "8701    浙江省\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "85885789\n",
      "1460    俄罗斯\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1689423148\n",
      "114432    上海市\n",
      "Name: city, dtype: object\n",
      "2038288511\n",
      "148548    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2991305107\n",
      "177358    江苏省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1904320912\n",
      "129591    浙江省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "1011376503\n",
      "43308    北京市\n",
      "Name: city, dtype: object\n",
      "1908730660\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1689440632\n",
      "114436    上海市\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1758399104\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1689423148\n",
      "114432    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1689423164\n",
      "114432    上海市\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "1904320912\n",
      "129591    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1020290923\n",
      "50501    北京市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1952057498\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "1908730660\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1952057500\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1689423148\n",
      "114432    上海市\n",
      "Name: city, dtype: object\n",
      "963047938\n",
      "12787    湖南省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1020290804\n",
      "50501    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1091353199\n",
      "94806    美国\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "387103375\n",
      "3162    美国\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "2006924522\n",
      "142875    广东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1952057500\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1553724848\n",
      "112150    俄罗斯\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "3379559847\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "975879189\n",
      "18811    江苏省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2046859776\n",
      "150404    北京市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2334774905\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1982272672\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "2008669070\n",
      "144325    广东省\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2047655394\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "2047654553\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1840735882\n",
      "122262    浙江省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2334828865\n",
      "167957    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "963047938\n",
      "12787    湖南省\n",
      "Name: city, dtype: object\n",
      "1982272961\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1853735858\n",
      "123740    北京市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1011376503\n",
      "43308    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2991305107\n",
      "177358    江苏省\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "2047654499\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1021551797\n",
      "61734    江苏省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "704239710\n",
      "8682    浙江省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "3379559857\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "2606862299\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "2009169909\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1952057500\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "1021340469\n",
      "57411    上海市\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "704261553\n",
      "8682    浙江省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "3050021227\n",
      "182443    广东省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2049972229\n",
      "151600    河南省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "2334899961\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "3379559824\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "593105003\n",
      "5810    美国\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1904320912\n",
      "129591    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2047654495\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "704239710\n",
      "8682    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3379559853\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "2047654498\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "3301651005\n",
      "211172    美国\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1922453164\n",
      "131775    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1876716247\n",
      "126481    北京市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1982272672\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "3659715729\n",
      "380834    北京市\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3379559868\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "2351790413\n",
      "168350    美国\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2606862329\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1877459172\n",
      "126585    湖北省\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "246160525\n",
      "3008    广东省\n",
      "Name: city, dtype: object\n",
      "2213805133\n",
      "166435    日本\n",
      "Name: city, dtype: object\n",
      "1020290804\n",
      "50501    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "668304535\n",
      "7668    美国\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "246164515\n",
      "3008    广东省\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "244986381\n",
      "2583    北京市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2047654499\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "704261553\n",
      "8682    浙江省\n",
      "Name: city, dtype: object\n",
      "1908772632\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "2047654557\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2046859776\n",
      "150404    北京市\n",
      "Name: city, dtype: object\n",
      "1982272672\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "706596393\n",
      "8701    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1982272961\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "3679197330\n",
      "401496    江苏省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1011376503\n",
      "43308    北京市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2334773925\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "2334885508\n",
      "167973    上海市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2606862259\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "3597460177\n",
      "253739    美国\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1963899777\n",
      "137870    四川省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1952057498\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "2038288511\n",
      "148548    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "2606862299\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "3379559825\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1877459172\n",
      "126585    湖北省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1982272961\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "246160525\n",
      "3008    广东省\n",
      "Name: city, dtype: object\n",
      "2334885508\n",
      "167973    上海市\n",
      "Name: city, dtype: object\n",
      "1689431547\n",
      "114434    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "3597460125\n",
      "253739    美国\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1689440632\n",
      "114436    上海市\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3597460177\n",
      "253739    美国\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "3042987551\n",
      "181419    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "2606862329\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "3379559853\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2334885508\n",
      "167973    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "3355815534\n",
      "216390    吉林省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "2334885508\n",
      "167973    上海市\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1861389854\n",
      "124360    上海市\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1876716247\n",
      "126481    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1879365484\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "2606862329\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1952057498\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1952057498\n",
      "137483    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1021551797\n",
      "61734    江苏省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "2048510337\n",
      "151145    陕西省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2038288511\n",
      "148548    浙江省\n",
      "Name: city, dtype: object\n",
      "1877459172\n",
      "126585    湖北省\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3435339119\n",
      "234007    美国\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1689423164\n",
      "114432    上海市\n",
      "Name: city, dtype: object\n",
      "2046859776\n",
      "150404    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1010942370\n",
      "43298    澳门\n",
      "Name: city, dtype: object\n",
      "2334828865\n",
      "167957    上海市\n",
      "Name: city, dtype: object\n",
      "3379559854\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "244986381\n",
      "2583    北京市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "2049972229\n",
      "151600    河南省\n",
      "Name: city, dtype: object\n",
      "3379559832\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "3659715722\n",
      "380834    北京市\n",
      "Name: city, dtype: object\n",
      "2334828865\n",
      "167957    上海市\n",
      "Name: city, dtype: object\n",
      "1758402897\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2334899957\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1908772632\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1876716247\n",
      "126481    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "3023793038\n",
      "179060    北京市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2334885508\n",
      "167973    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3379559831\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1011376503\n",
      "43308    北京市\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "1020190501\n",
      "49996    陕西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1982272961\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "3659699685\n",
      "380796    北京市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1865326449\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3603344164\n",
      "254471    德国\n",
      "Name: city, dtype: object\n",
      "1758398618\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2334773920\n",
      "167944    浙江省\n",
      "Name: city, dtype: object\n",
      "3042987551\n",
      "181419    浙江省\n",
      "Name: city, dtype: object\n",
      "1843138571\n",
      "122631    黑龙江省\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "2009041108\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "2606862259\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "1908772766\n",
      "130169    山东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2046859776\n",
      "150404    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "2049972229\n",
      "151600    河南省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1880959638\n",
      "127395    广东省\n",
      "Name: city, dtype: object\n",
      "1991472096\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1881431139\n",
      "127466    广东省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1865326449\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "668304641\n",
      "7668    美国\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2991778543\n",
      "177473    江苏省\n",
      "Name: city, dtype: object\n",
      "2606862329\n",
      "170705    美国\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1863227384\n",
      "124525    广东省\n",
      "Name: city, dtype: object\n",
      "1879365484\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "965678037\n",
      "16460    广东省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1906352388\n",
      "130065    北京市\n",
      "Name: city, dtype: object\n",
      "1020290923\n",
      "50501    北京市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1995755637\n",
      "142158    北京市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "2334828865\n",
      "167957    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1876716247\n",
      "126481    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "2334828865\n",
      "167957    上海市\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1020190501\n",
      "49996    陕西省\n",
      "Name: city, dtype: object\n",
      "1861389854\n",
      "124360    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1011376503\n",
      "43308    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3379559844\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3659715729\n",
      "380834    北京市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1982272672\n",
      "140663    广东省\n",
      "Name: city, dtype: object\n",
      "1861389855\n",
      "124360    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1758398639\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1904320912\n",
      "129591    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "2334899961\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "3195759369\n",
      "190470    加拿大\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1908685468\n",
      "130167    山东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "1944100756\n",
      "136212    江苏省\n",
      "Name: city, dtype: object\n",
      "2047654497\n",
      "150739    北京市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1022551683\n",
      "68533    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2334899957\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "3712015370\n",
      "446408    青海省\n",
      "Name: city, dtype: object\n",
      "2334899959\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1091353195\n",
      "94806    美国\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "24353179\n",
      "607    北京市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1553724848\n",
      "112150    俄罗斯\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1896397515\n",
      "128945    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1961894485\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2334899957\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "246160525\n",
      "3008    广东省\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1081419388\n",
      "94648    美国\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "1991510898\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "3379559843\n",
      "232170    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "1865325821\n",
      "124910    北京市\n",
      "Name: city, dtype: object\n",
      "1860441602\n",
      "124316    福建省\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "2064410896\n",
      "155340    北京市\n",
      "Name: city, dtype: object\n",
      "2843134218\n",
      "174165    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "1938545364\n",
      "134528    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1961893890\n",
      "137772    山西省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1877459172\n",
      "126585    湖北省\n",
      "Name: city, dtype: object\n",
      "1877459172\n",
      "126585    湖北省\n",
      "Name: city, dtype: object\n",
      "1007296843\n",
      "39449    浙江省\n",
      "Name: city, dtype: object\n",
      "2043218233\n",
      "149596    北京市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "3679205227\n",
      "401513    江苏省\n",
      "Name: city, dtype: object\n",
      "1689431207\n",
      "114434    上海市\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "1758349708\n",
      "118526    浙江省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "3597460125\n",
      "253739    美国\n",
      "Name: city, dtype: object\n",
      "3027682452\n",
      "179916    四川省\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1992384605\n",
      "141689    福建省\n",
      "Name: city, dtype: object\n",
      "3677291048\n",
      "393060    天津市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1991532693\n",
      "141479    浙江省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1879384701\n",
      "126860    广东省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "1709245870\n",
      "115958    香港\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "653738498\n",
      "7390    广东省\n",
      "Name: city, dtype: object\n",
      "1857788454\n",
      "124034    浙江省\n",
      "Name: city, dtype: object\n",
      "2334899962\n",
      "167976    上海市\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n",
      "2049800502\n",
      "151533    浙江省\n",
      "Name: city, dtype: object\n",
      "1022593395\n",
      "68617    上海市\n",
      "Name: city, dtype: object\n",
      "2009042477\n",
      "144492    浙江省\n",
      "Name: city, dtype: object\n",
      "1680047541\n",
      "114275    上海市\n",
      "Name: city, dtype: object\n"
     ]
    }
   ],
   "source": [
    "def trans(ip):\n",
    "    ips = ip.strip().split('.')\n",
    "    ip_int = int(ips[0])*255*255*255 + int(ips[1])*255*255 + int(ips[2])*255 + int(ips[3]) * 1\n",
    "    print(ip_int)\n",
    "    print(ip_df[(ip_int >= ip_df['start']) & (ip_int <= ip_df['end'])]['city'])\n",
    "    return ip_df[(ip_int >= ip_df['start']) & (ip_int <= ip_df['end'])]['city'].iloc[0]\n",
    "# 订单表增加一列 province_by_ip\n",
    "# 根据 user_ip 来计算相应的下单省份\n",
    "order_df['province_by_ip'] = order_df['user_ip'].apply(lambda x:trans(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 250,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:2: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.\n",
      "  \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>province_by_ip</th>\n",
       "      <th>user_id</th>\n",
       "      <th>province</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>province_by_ip</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>上海市</th>\n",
       "      <td>371</td>\n",
       "      <td>371</td>\n",
       "      <td>上海市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>俄罗斯</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>俄罗斯</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>加拿大</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>加拿大</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>北京市</th>\n",
       "      <td>153</td>\n",
       "      <td>153</td>\n",
       "      <td>北京市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>吉林省</th>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>吉林省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>四川省</th>\n",
       "      <td>17</td>\n",
       "      <td>17</td>\n",
       "      <td>四川省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>天津市</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>天津市</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>山东省</th>\n",
       "      <td>26</td>\n",
       "      <td>26</td>\n",
       "      <td>山东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>山西省</th>\n",
       "      <td>88</td>\n",
       "      <td>88</td>\n",
       "      <td>山西省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>广东省</th>\n",
       "      <td>131</td>\n",
       "      <td>131</td>\n",
       "      <td>广东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>德国</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>德国</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>日本</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>日本</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>江苏省</th>\n",
       "      <td>29</td>\n",
       "      <td>29</td>\n",
       "      <td>江苏省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>河南省</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>河南省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>浙江省</th>\n",
       "      <td>263</td>\n",
       "      <td>263</td>\n",
       "      <td>浙江省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>湖北省</th>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>湖北省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>湖南省</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>湖南省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>澳门</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>澳门</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>福建省</th>\n",
       "      <td>113</td>\n",
       "      <td>113</td>\n",
       "      <td>福建省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>美国</th>\n",
       "      <td>34</td>\n",
       "      <td>34</td>\n",
       "      <td>美国</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>陕西省</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>陕西省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>青海省</th>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>青海省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>香港</th>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>香港</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>黑龙江省</th>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>黑龙江省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                province_by_ip  user_id province\n",
       "province_by_ip                                  \n",
       "上海市                        371      371      上海市\n",
       "俄罗斯                          4        4      俄罗斯\n",
       "加拿大                          1        1      加拿大\n",
       "北京市                        153      153      北京市\n",
       "吉林省                         15       15      吉林省\n",
       "四川省                         17       17      四川省\n",
       "天津市                          3        3      天津市\n",
       "山东省                         26       26      山东省\n",
       "山西省                         88       88      山西省\n",
       "广东省                        131      131      广东省\n",
       "德国                           1        1       德国\n",
       "日本                           2        2       日本\n",
       "江苏省                         29       29      江苏省\n",
       "河南省                          4        4      河南省\n",
       "浙江省                        263      263      浙江省\n",
       "湖北省                          6        6      湖北省\n",
       "湖南省                          2        2      湖南省\n",
       "澳门                           1        1       澳门\n",
       "福建省                        113      113      福建省\n",
       "美国                          34       34       美国\n",
       "陕西省                          4        4      陕西省\n",
       "青海省                         14       14      青海省\n",
       "香港                          14       14       香港\n",
       "黑龙江省                        10       10     黑龙江省"
      ]
     },
     "execution_count": 250,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 开始统计各省下单情况\n",
    "province_count = order_df.groupby(['province_by_ip'])['province_by_ip','user_id'].count()\n",
    "province_count\n",
    "# 保存结果 \n",
    "province_count['province'] = province_count.index\n",
    "province_count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 253,
   "metadata": {},
   "outputs": [],
   "source": [
    "province_count_df = pd.DataFrame(columns=['province','count'])\n",
    "province_count_df = province_count_df.append([\n",
    "        {\"province\":\"南海诸岛\",\"count\":0},\n",
    "        {\"province\": '北京市', \"count\": 0},\n",
    "        {\"province\": '天津市', \"count\": 0},\n",
    "        {\"province\": '上海市', \"count\": 0},\n",
    "        {\"province\": '重庆', \"count\": 0},\n",
    "        {\"province\": '河北', \"count\": 0},\n",
    "        {\"province\": '河南省', \"count\": 0},\n",
    "        {\"province\": '云南', \"count\": 0},\n",
    "        {\"province\": '辽宁', \"count\": 0},\n",
    "        {\"province\": '黑龙江省', \"count\": 0},\n",
    "        {\"province\": '湖南省', \"count\": 0},\n",
    "        {\"province\": '安徽', \"count\": 0},\n",
    "        {\"province\": '山东省', \"count\": 0},\n",
    "        {\"province\": '新疆', \"count\": 0},\n",
    "        {\"province\": '江苏省', \"count\": 0},\n",
    "        {\"province\": '浙江省', \"count\": 0},\n",
    "        {\"province\": '江西', \"count\": 0},\n",
    "        {\"province\": '湖北省', \"count\": 0},\n",
    "        {\"province\": '广西', \"count\": 0},\n",
    "        {\"province\": '甘肃', \"count\": 0},\n",
    "        {\"province\": '山西省', \"count\": 0},\n",
    "        {\"province\": '内蒙古', \"count\": 0},\n",
    "        {\"province\": '陕西省', \"count\": 0},\n",
    "        {\"province\": '吉林省', \"count\": 0},\n",
    "        {\"province\": '福建省', \"count\": 0},\n",
    "        {\"province\": '贵州', \"count\": 0},\n",
    "        {\"province\": '广东省', \"count\": 0},\n",
    "        {\"province\": '青海省', \"count\": 0},\n",
    "        {\"province\": '西藏', \"count\": 0},\n",
    "        {\"province\": '四川省', \"count\": 0},\n",
    "        {\"province\": '宁夏', \"count\": 0},\n",
    "        {\"province\": '海南', \"count\": 0},\n",
    "        {\"province\": '台湾', \"count\": 0},\n",
    "        {\"province\": '香港', \"count\": 0},\n",
    "        {\"province\": '澳门', \"count\": 0}\n",
    "      ])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 254,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 构造省份分布结果表   并存入数据库 表 province_order_distribution\n",
    "province_count_df = province_count_df.merge(province_count,left_on=['province'], right_on=['province'],how='left')\n",
    "province_count_df['count'] = province_count_df['province_by_ip']\n",
    "province_count_df['count'].fillna(0,inplace=True)\n",
    "province_count_df=province_count_df[['province','count']]\n",
    "province_count_df['province'] = province_count_df['province'].apply(lambda x:x.replace('市','').replace('省',''))\n",
    "province_count_df.to_sql(\"province_order_distribution\",engine,index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 255,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>visitor_ip</th>\n",
       "      <th>visit_time</th>\n",
       "      <th>two_time</th>\n",
       "      <th>user_id</th>\n",
       "      <th>phone_num</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>visit_link</th>\n",
       "      <th>source</th>\n",
       "      <th>point_fee</th>\n",
       "      <th>residence_time</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>visit_events</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>chargeRequest</th>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "      <td>596</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>launch</th>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "      <td>803</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>pageView</th>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "      <td>4292</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               visitor_ip  visit_time  two_time  user_id  phone_num  goods_id  \\\n",
       "visit_events                                                                    \n",
       "chargeRequest         596         596       596      596        596       596   \n",
       "launch                803         803       803      803        803       803   \n",
       "pageView             4292        4292      4292     4292       4292      4292   \n",
       "\n",
       "               visit_link  source  point_fee  residence_time  \n",
       "visit_events                                                  \n",
       "chargeRequest         596     596        596             596  \n",
       "launch                803     803        803             803  \n",
       "pageView             4292    4292       4292            4292  "
      ]
     },
     "execution_count": 255,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 下面开始计算漏斗模型  by 渠道维度  四个事件转换\n",
    "# 网站浏览 → 提交订单 → 支付订单 → 支付成功\n",
    "visit_df.groupby(['visit_events']).count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 256,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>visit_events</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>launch</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>pageView</td>\n",
       "      <td>257</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>launch</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>pageView</td>\n",
       "      <td>497</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>launch</td>\n",
       "      <td>220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>pageView</td>\n",
       "      <td>1174</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>launch</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>pageView</td>\n",
       "      <td>494</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>直通车</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>直通车</td>\n",
       "      <td>launch</td>\n",
       "      <td>249</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>直通车</td>\n",
       "      <td>pageView</td>\n",
       "      <td>1394</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>launch</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>pageView</td>\n",
       "      <td>476</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   source   visit_events  count\n",
       "0    淘宝搜索  chargeRequest     45\n",
       "1    淘宝搜索         launch     45\n",
       "2    淘宝搜索       pageView    257\n",
       "3    淘宝橱窗  chargeRequest     68\n",
       "4    淘宝橱窗         launch    104\n",
       "5    淘宝橱窗       pageView    497\n",
       "6    淘宝直播  chargeRequest    149\n",
       "7    淘宝直播         launch    220\n",
       "8    淘宝直播       pageView   1174\n",
       "9    淘宝社区  chargeRequest     70\n",
       "10   淘宝社区         launch     92\n",
       "11   淘宝社区       pageView    494\n",
       "12    直通车  chargeRequest    198\n",
       "13    直通车         launch    249\n",
       "14    直通车       pageView   1394\n",
       "15    聚划算  chargeRequest     66\n",
       "16    聚划算         launch     93\n",
       "17    聚划算       pageView    476"
      ]
     },
     "execution_count": 256,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "funnel = visit_df.groupby(['source','visit_events'])['user_id'].count().reset_index()\n",
    "funnel.rename(columns={'user_id':'count'},inplace=True)\n",
    "funnel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 257,
   "metadata": {},
   "outputs": [],
   "source": [
    "source_list = list(funnel.source.unique())\n",
    "visit_events_list = list(funnel.visit_events.unique())\n",
    "funnel_df = pd.DataFrame(columns=['source','pageView','launch','chargeRequest'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 258,
   "metadata": {},
   "outputs": [],
   "source": [
    "#构造漏斗结构\n",
    "for source in source_list:\n",
    "    data = {\"source\":source}\n",
    "    for visit_events in visit_events_list:\n",
    "        data[visit_events] = funnel[(funnel['source']==source) & (funnel['visit_events']==visit_events)]['count'].iloc[0]\n",
    "    funnel_df = funnel_df.append(data,ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 259,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>pageView</th>\n",
       "      <th>launch</th>\n",
       "      <th>chargeRequest</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>257</td>\n",
       "      <td>45</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>497</td>\n",
       "      <td>104</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1174</td>\n",
       "      <td>220</td>\n",
       "      <td>149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>494</td>\n",
       "      <td>92</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>直通车</td>\n",
       "      <td>1394</td>\n",
       "      <td>249</td>\n",
       "      <td>198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>476</td>\n",
       "      <td>93</td>\n",
       "      <td>66</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  source pageView launch chargeRequest\n",
       "0   淘宝搜索      257     45            45\n",
       "1   淘宝橱窗      497    104            68\n",
       "2   淘宝直播     1174    220           149\n",
       "3   淘宝社区      494     92            70\n",
       "4    直通车     1394    249           198\n",
       "5    聚划算      476     93            66"
      ]
     },
     "execution_count": 259,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "funnel_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 260,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算支付成功订单 列 \n",
    "finish_order_col = order_df[order_df['order_active']=='支付成功'].groupby(['click_source'])['order_active'].count().reset_index()\n",
    "finish_order_col.rename(columns={'click_source':'source','order_active':\"finished_count\"},inplace=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 261,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>pageView</th>\n",
       "      <th>launch</th>\n",
       "      <th>chargeRequest</th>\n",
       "      <th>finished_count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>257</td>\n",
       "      <td>45</td>\n",
       "      <td>45</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>497</td>\n",
       "      <td>104</td>\n",
       "      <td>68</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1174</td>\n",
       "      <td>220</td>\n",
       "      <td>149</td>\n",
       "      <td>146</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>494</td>\n",
       "      <td>92</td>\n",
       "      <td>70</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>直通车</td>\n",
       "      <td>1394</td>\n",
       "      <td>249</td>\n",
       "      <td>198</td>\n",
       "      <td>92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>476</td>\n",
       "      <td>93</td>\n",
       "      <td>66</td>\n",
       "      <td>180</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  source pageView launch chargeRequest  finished_count\n",
       "0   淘宝搜索      257     45            45              42\n",
       "1   淘宝橱窗      497    104            68              77\n",
       "2   淘宝直播     1174    220           149             146\n",
       "3   淘宝社区      494     92            70              69\n",
       "4    直通车     1394    249           198              92\n",
       "5    聚划算      476     93            66             180"
      ]
     },
     "execution_count": 261,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "funnel_df = funnel_df.merge(finish_order_col,left_on=['source'],right_on=['source'],how='left')\n",
    "funnel_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将模型持久化\n",
    "funnel_df.to_sql(\"funnel_model\",engine,index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 300,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 323,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'overall_operation_index': {'PV': 4292,\n",
       "  'UV': 300,\n",
       "  'per_capita_page': 14.31,\n",
       "  'total_order_quantity': 596,\n",
       "  'total_visit_num': 5095,\n",
       "  'access_to_order_conversion_rate': 0.1169774288518155,\n",
       "  'gvm': 64842.34,\n",
       "  'refund_charge': 13928.3,\n",
       "  'sales_amount': 50914.03999999999,\n",
       "  'unit_price_per_customer': 49.64957120980092,\n",
       "  'sales_gross_profit': 24026.619999999995,\n",
       "  'gross_profit_margin': 0.37053906444462054},\n",
       " 'website_traffic_metrics': {'cost_of_visitors': 21.472,\n",
       "  'avg_visit_time': 42.50500790722193},\n",
       " 'sales_conversion_index': {'number_of_times_to_add_shopping_cart': 153,\n",
       "  'number_of_times_to_add_shopping_cart_buyers': 72,\n",
       "  'number_of_items_added_to_shopping_cart': 121,\n",
       "  'cart_to_pay_the_number_of_buyers': 69,\n",
       "  'cart_to_payment_rate': 0.9583333333333334,\n",
       "  'orders_num': 1306,\n",
       "  'orders_amount': 64842.34,\n",
       "  'order_buyers': 441,\n",
       "  'visit_to_order_rate': 1.47,\n",
       "  'payment_amount': 33938.420000000006,\n",
       "  'payment_user_number': 267,\n",
       "  'payment_goods_number': 675,\n",
       "  'website_visitors': 722,\n",
       "  'browse_pay_buyer_conversion_rate': 0.3698060941828255,\n",
       "  'order_conversion_rate_of_payment_amount': 0.5233990630196259,\n",
       "  'order_payment_buyer_number_conversion_rate': 0.6054421768707483,\n",
       "  'avg_pay_to_finish': 62.06738131699847,\n",
       "  'number_of_successful_orders': 675,\n",
       "  'successful_transaction_amount': 33938.420000000006,\n",
       "  'number_of_successful_buyers': 267,\n",
       "  'number_of_products_successfully_traded': 512,\n",
       "  'number_of_failed_orders': 327,\n",
       "  'failed_transaction_amount': 15731.82,\n",
       "  'number_of_buyers_of_failed_orders': 137,\n",
       "  'number_of_products_failed_traded': 275,\n",
       "  'total_refund_order': 271,\n",
       "  'refund_amount': 13928.3,\n",
       "  'refund_rate': 0.20750382848392038},\n",
       " 'wind_control_index': {'show_img_count': 58007,\n",
       "  'buyer_evaluation_number': 17151540,\n",
       "  'f_comments_rate': 0.9993073508268062,\n",
       "  'n_comments_rate': 0.0006926491731937774},\n",
       " 'marketing_activity_index': {'new_visitors': 884,\n",
       "  'total_visit_times': 5095,\n",
       "  'UV_order_rate': 0.6742081447963801}}"
      ]
     },
     "execution_count": 323,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 指标持久化\n",
    "result = {\n",
    "    \"overall_operation_index\":{\"PV\":PV,\"UV\":UV,\"per_capita_page\":per_capita_page,\"total_order_quantity\":total_order_quantity,\"total_visit_num\":total_visit_num,\"access_to_order_conversion_rate\":access_to_order_conversion_rate,\"gvm\":gvm,\"refund_charge\":refund_charge,\"sales_amount\":sales_amount,\"unit_price_per_customer\":unit_price_per_customer,\"sales_gross_profit\":sales_gross_profit,\"gross_profit_margin\":gross_profit_margin},\n",
    "    \"website_traffic_metrics\":{\"cost_of_visitors\":cost_of_visitors,\"avg_visit_time\":avg_visit_time},\n",
    "    \"sales_conversion_index\":{\"number_of_times_to_add_shopping_cart\":number_of_times_to_add_shopping_cart,\"number_of_times_to_add_shopping_cart_buyers\":number_of_times_to_add_shopping_cart_buyers,\"number_of_items_added_to_shopping_cart\":number_of_items_added_to_shopping_cart,\"cart_to_pay_the_number_of_buyers\":cart_to_pay_the_number_of_buyers,\"cart_to_payment_rate\":cart_to_payment_rate,\"orders_num\":orders_num,\"orders_amount\":orders_amount,\"order_buyers\":order_buyers,\"visit_to_order_rate\":visit_to_order_rate,\"payment_amount\":payment_amount,\"payment_user_number\":payment_user_number,\"payment_goods_number\":payment_goods_number,\"website_visitors\":website_visitors,\"browse_pay_buyer_conversion_rate\":browse_pay_buyer_conversion_rate,\"order_conversion_rate_of_payment_amount\":order_conversion_rate_of_payment_amount,\"order_payment_buyer_number_conversion_rate\":order_payment_buyer_number_conversion_rate,\"avg_pay_to_finish\":avg_pay_to_finish,\n",
    "                             \"number_of_successful_orders\":number_of_successful_orders,\"successful_transaction_amount\":successful_transaction_amount,\"number_of_successful_buyers\":number_of_successful_buyers,\"number_of_products_successfully_traded\":number_of_products_successfully_traded,\"number_of_failed_orders\":number_of_failed_orders,\"failed_transaction_amount\":failed_transaction_amount,\"number_of_buyers_of_failed_orders\":number_of_buyers_of_failed_orders,\"number_of_products_failed_traded\":number_of_products_failed_traded,\"total_refund_order\":total_refund_order,\"refund_amount\":refund_amount,\"refund_rate\":refund_rate},\n",
    "    \"wind_control_index\":{\"show_img_count\":show_img_count,\"buyer_evaluation_number\":buyer_evaluation_number,\"f_comments_rate\":f_comments_rate,\"n_comments_rate\":n_comments_rate},\n",
    "    \"marketing_activity_index\":{\"new_visitors\":new_visitors,\"total_visit_times\":total_visit_times,\"UV_order_rate\":UV_order_rate}\n",
    "    \n",
    "}\n",
    "result\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 281,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>直通车</td>\n",
       "      <td>198</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>66</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  source  count\n",
       "0   淘宝搜索     45\n",
       "1   淘宝橱窗     68\n",
       "2   淘宝直播    149\n",
       "3   淘宝社区     70\n",
       "4    直通车    198\n",
       "5    聚划算     66"
      ]
     },
     "execution_count": 281,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# by推广订单数持久化\n",
    "order_by_source = order_by_source.reset_index()\n",
    "order_by_source.rename(columns={'goods_id':'count'},inplace=True)\n",
    "order_by_source.to_sql(\"order_by_source\",engine,index=False)\n",
    "order_by_source"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 283,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>直通车</td>\n",
       "      <td>282</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>100</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  source  count\n",
       "0   淘宝搜索     60\n",
       "1   淘宝橱窗    115\n",
       "2   淘宝直播    231\n",
       "3   淘宝社区     96\n",
       "4    直通车    282\n",
       "5    聚划算    100"
      ]
     },
     "execution_count": 283,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# by推广访客数持久化\n",
    "new_visitors_df = new_visitors_df.reset_index()\n",
    "new_visitors_df.rename(columns={'user_id':'count'},inplace=True)\n",
    "new_visitors_df.to_sql(\"new_visitors_df\",engine,index=False)\n",
    "new_visitors_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 289,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:2: FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.\n",
      "  \n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>source</th>\n",
       "      <th>point_fee</th>\n",
       "      <th>profit</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>淘宝搜索</td>\n",
       "      <td>400.4</td>\n",
       "      <td>16230.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>淘宝橱窗</td>\n",
       "      <td>755.5</td>\n",
       "      <td>32988.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1732.1</td>\n",
       "      <td>72516.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>淘宝社区</td>\n",
       "      <td>760.5</td>\n",
       "      <td>31175.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>直通车</td>\n",
       "      <td>2078.4</td>\n",
       "      <td>88432.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>聚划算</td>\n",
       "      <td>714.7</td>\n",
       "      <td>32782.80</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  source  point_fee    profit\n",
       "0   淘宝搜索      400.4  16230.10\n",
       "1   淘宝橱窗      755.5  32988.70\n",
       "2   淘宝直播     1732.1  72516.30\n",
       "3   淘宝社区      760.5  31175.30\n",
       "4    直通车     2078.4  88432.06\n",
       "5    聚划算      714.7  32782.80"
      ]
     },
     "execution_count": 289,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# by推广利润持久化\n",
    "profit_by_source = visit_and_goods.groupby(['source'])['point_fee','profit'].sum().reset_index()\n",
    "profit_by_source.to_sql(\"profit_by_source\",engine,index=False)\n",
    "profit_by_source"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 291,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>visitor_ip</th>\n",
       "      <th>visit_time</th>\n",
       "      <th>two_time</th>\n",
       "      <th>user_id</th>\n",
       "      <th>phone_num</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>visit_link</th>\n",
       "      <th>visit_events</th>\n",
       "      <th>source</th>\n",
       "      <th>point_fee</th>\n",
       "      <th>residence_time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>101.226.65.107</td>\n",
       "      <td>1571399151</td>\n",
       "      <td>1571399167</td>\n",
       "      <td>19500</td>\n",
       "      <td>1503476****</td>\n",
       "      <td>24849</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=532038730419***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.9</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>121.41.112.148</td>\n",
       "      <td>1571390248</td>\n",
       "      <td>1571390278</td>\n",
       "      <td>8666500</td>\n",
       "      <td>1518028****</td>\n",
       "      <td>14065</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=573659715732***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.3</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>114.247.56.183</td>\n",
       "      <td>1571336033</td>\n",
       "      <td>1571336067</td>\n",
       "      <td>267250</td>\n",
       "      <td>1529163****</td>\n",
       "      <td>28803</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=590428245179***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>171.118.180.243</td>\n",
       "      <td>1571407791</td>\n",
       "      <td>1571407812</td>\n",
       "      <td>11601500</td>\n",
       "      <td>1304833****</td>\n",
       "      <td>18289</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=17302099374****...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.6</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571353981</td>\n",
       "      <td>1571354011</td>\n",
       "      <td>8215250</td>\n",
       "      <td>1351254****</td>\n",
       "      <td>7692</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=601449111587***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>直通车</td>\n",
       "      <td>1.4</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5686</th>\n",
       "      <td>178.140.51.103</td>\n",
       "      <td>1571375258</td>\n",
       "      <td>1571375305</td>\n",
       "      <td>11646500</td>\n",
       "      <td>1755721****</td>\n",
       "      <td>9653</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=561027772418***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.9</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5687</th>\n",
       "      <td>120.27.47.33</td>\n",
       "      <td>1571341423</td>\n",
       "      <td>1571341493</td>\n",
       "      <td>981000</td>\n",
       "      <td>1841007****</td>\n",
       "      <td>4775</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=586454071825***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.8</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5688</th>\n",
       "      <td>65.208.151.115</td>\n",
       "      <td>1571354791</td>\n",
       "      <td>1571354804</td>\n",
       "      <td>2200750</td>\n",
       "      <td>1347045****</td>\n",
       "      <td>9846</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=570981208552***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>直通车</td>\n",
       "      <td>0.4</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5689</th>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571347900</td>\n",
       "      <td>1571347935</td>\n",
       "      <td>1449250</td>\n",
       "      <td>1368294****</td>\n",
       "      <td>13701</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=520237346984***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.7</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5690</th>\n",
       "      <td>112.126.73.56</td>\n",
       "      <td>1571328881</td>\n",
       "      <td>1571328892</td>\n",
       "      <td>239250</td>\n",
       "      <td>1553383****</td>\n",
       "      <td>10680</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=600528109589***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5691 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           visitor_ip  visit_time    two_time   user_id    phone_num  \\\n",
       "0      101.226.65.107  1571399151  1571399167     19500  1503476****   \n",
       "1      121.41.112.148  1571390248  1571390278   8666500  1518028****   \n",
       "2      114.247.56.183  1571336033  1571336067    267250  1529163****   \n",
       "3     171.118.180.243  1571407791  1571407812  11601500  1304833****   \n",
       "4       39.108.165.98  1571353981  1571354011   8215250  1351254****   \n",
       "...               ...         ...         ...       ...          ...   \n",
       "5686   178.140.51.103  1571375258  1571375305  11646500  1755721****   \n",
       "5687     120.27.47.33  1571341423  1571341493    981000  1841007****   \n",
       "5688   65.208.151.115  1571354791  1571354804   2200750  1347045****   \n",
       "5689    39.108.165.98  1571347900  1571347935   1449250  1368294****   \n",
       "5690    112.126.73.56  1571328881  1571328892    239250  1553383****   \n",
       "\n",
       "      goods_id                                         visit_link  \\\n",
       "0        24849  //detail.tmall.com/item.htm?id=532038730419***...   \n",
       "1        14065  //detail.tmall.com/item.htm?id=573659715732***...   \n",
       "2        28803  //detail.tmall.com/item.htm?id=590428245179***...   \n",
       "3        18289  //detail.tmall.com/item.htm?id=17302099374****...   \n",
       "4         7692  //detail.tmall.com/item.htm?id=601449111587***...   \n",
       "...        ...                                                ...   \n",
       "5686      9653  //detail.tmall.com/item.htm?id=561027772418***...   \n",
       "5687      4775  //detail.tmall.com/item.htm?id=586454071825***...   \n",
       "5688      9846  //detail.tmall.com/item.htm?id=570981208552***...   \n",
       "5689     13701  //detail.tmall.com/item.htm?id=520237346984***...   \n",
       "5690     10680  //detail.tmall.com/item.htm?id=600528109589***...   \n",
       "\n",
       "       visit_events source  point_fee  residence_time  \n",
       "0     chargeRequest   淘宝直播        1.9              16  \n",
       "1     chargeRequest   淘宝直播        1.3              30  \n",
       "2     chargeRequest   淘宝直播        1.0              34  \n",
       "3     chargeRequest   淘宝直播        0.6              21  \n",
       "4     chargeRequest    直通车        1.4              30  \n",
       "...             ...    ...        ...             ...  \n",
       "5686         launch   淘宝直播        1.9              47  \n",
       "5687         launch   淘宝直播        0.8              70  \n",
       "5688         launch    直通车        0.4              13  \n",
       "5689         launch   淘宝直播        0.7              35  \n",
       "5690         launch   淘宝直播        1.0              11  \n",
       "\n",
       "[5691 rows x 11 columns]"
      ]
     },
     "execution_count": 291,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 二跳时间df持久化\n",
    "visit_df.to_sql(\"visit_df\",engine,index=False)\n",
    "visit_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 302,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 303,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>overall_operation_index</th>\n",
       "      <th>website_traffic_metrics</th>\n",
       "      <th>sales_conversion_index</th>\n",
       "      <th>wind_control_index</th>\n",
       "      <th>marketing_activity_index</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>{'PV': 4292, 'UV': 300, 'per_capita_page': 14....</td>\n",
       "      <td>{'cost_of_visitors': 21.472, 'avg_visit_time':...</td>\n",
       "      <td>{'number_of_times_to_add_shopping_cart': 153, ...</td>\n",
       "      <td>{'show_img_count': 58007, 'buyer_evaluation_nu...</td>\n",
       "      <td>{'new_visitors': 884, 'total_visit_times': 509...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             overall_operation_index  \\\n",
       "0  {'PV': 4292, 'UV': 300, 'per_capita_page': 14....   \n",
       "\n",
       "                             website_traffic_metrics  \\\n",
       "0  {'cost_of_visitors': 21.472, 'avg_visit_time':...   \n",
       "\n",
       "                              sales_conversion_index  \\\n",
       "0  {'number_of_times_to_add_shopping_cart': 153, ...   \n",
       "\n",
       "                                  wind_control_index  \\\n",
       "0  {'show_img_count': 58007, 'buyer_evaluation_nu...   \n",
       "\n",
       "                            marketing_activity_index  \n",
       "0  {'new_visitors': 884, 'total_visit_times': 509...  "
      ]
     },
     "execution_count": 303,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 324,
   "metadata": {},
   "outputs": [],
   "source": [
    "# result_df.to_sql(\"result_df\",engine,index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 347,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:3: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  This is separate from the ipykernel package so we can avoid doing imports until\n"
     ]
    }
   ],
   "source": [
    "# 对用户进行分析\n",
    "user_df = user_df[user_df['user_id'].notnull()]\n",
    "user_df['user_id'] = user_df['user_id'].astype(int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 348,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \n"
     ]
    }
   ],
   "source": [
    "# 将时间戳转换为时间\n",
    "user_df['register_time'] = user_df['register_time'].apply(lambda x:time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(x)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 355,
   "metadata": {},
   "outputs": [],
   "source": [
    "def trans_time(x):\n",
    "    if x!=0:\n",
    "        return time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime(x))\n",
    "    else:\n",
    "        return 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 356,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  \n"
     ]
    }
   ],
   "source": [
    "# 将时间戳转换为时间\n",
    "user_df['last_login_time'] = user_df['last_login_time'].apply(lambda x:trans_time(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 359,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 基本信息持久\n",
    "user_df.to_sql(\"user_basic_info\",engine,index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 358,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>visitor_ip</th>\n",
       "      <th>visit_time</th>\n",
       "      <th>two_time</th>\n",
       "      <th>user_id</th>\n",
       "      <th>phone_num</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>visit_link</th>\n",
       "      <th>visit_events</th>\n",
       "      <th>source</th>\n",
       "      <th>point_fee</th>\n",
       "      <th>residence_time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>101.226.65.107</td>\n",
       "      <td>1571399151</td>\n",
       "      <td>1571399167</td>\n",
       "      <td>19500</td>\n",
       "      <td>1503476****</td>\n",
       "      <td>24849</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=532038730419***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.9</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>121.41.112.148</td>\n",
       "      <td>1571390248</td>\n",
       "      <td>1571390278</td>\n",
       "      <td>8666500</td>\n",
       "      <td>1518028****</td>\n",
       "      <td>14065</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=573659715732***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.3</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>114.247.56.183</td>\n",
       "      <td>1571336033</td>\n",
       "      <td>1571336067</td>\n",
       "      <td>267250</td>\n",
       "      <td>1529163****</td>\n",
       "      <td>28803</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=590428245179***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>171.118.180.243</td>\n",
       "      <td>1571407791</td>\n",
       "      <td>1571407812</td>\n",
       "      <td>11601500</td>\n",
       "      <td>1304833****</td>\n",
       "      <td>18289</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=17302099374****...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.6</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571353981</td>\n",
       "      <td>1571354011</td>\n",
       "      <td>8215250</td>\n",
       "      <td>1351254****</td>\n",
       "      <td>7692</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=601449111587***...</td>\n",
       "      <td>chargeRequest</td>\n",
       "      <td>直通车</td>\n",
       "      <td>1.4</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5686</th>\n",
       "      <td>178.140.51.103</td>\n",
       "      <td>1571375258</td>\n",
       "      <td>1571375305</td>\n",
       "      <td>11646500</td>\n",
       "      <td>1755721****</td>\n",
       "      <td>9653</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=561027772418***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.9</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5687</th>\n",
       "      <td>120.27.47.33</td>\n",
       "      <td>1571341423</td>\n",
       "      <td>1571341493</td>\n",
       "      <td>981000</td>\n",
       "      <td>1841007****</td>\n",
       "      <td>4775</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=586454071825***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.8</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5688</th>\n",
       "      <td>65.208.151.115</td>\n",
       "      <td>1571354791</td>\n",
       "      <td>1571354804</td>\n",
       "      <td>2200750</td>\n",
       "      <td>1347045****</td>\n",
       "      <td>9846</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=570981208552***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>直通车</td>\n",
       "      <td>0.4</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5689</th>\n",
       "      <td>39.108.165.98</td>\n",
       "      <td>1571347900</td>\n",
       "      <td>1571347935</td>\n",
       "      <td>1449250</td>\n",
       "      <td>1368294****</td>\n",
       "      <td>13701</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=520237346984***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>0.7</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5690</th>\n",
       "      <td>112.126.73.56</td>\n",
       "      <td>1571328881</td>\n",
       "      <td>1571328892</td>\n",
       "      <td>239250</td>\n",
       "      <td>1553383****</td>\n",
       "      <td>10680</td>\n",
       "      <td>//detail.tmall.com/item.htm?id=600528109589***...</td>\n",
       "      <td>launch</td>\n",
       "      <td>淘宝直播</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5691 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           visitor_ip  visit_time    two_time   user_id    phone_num  \\\n",
       "0      101.226.65.107  1571399151  1571399167     19500  1503476****   \n",
       "1      121.41.112.148  1571390248  1571390278   8666500  1518028****   \n",
       "2      114.247.56.183  1571336033  1571336067    267250  1529163****   \n",
       "3     171.118.180.243  1571407791  1571407812  11601500  1304833****   \n",
       "4       39.108.165.98  1571353981  1571354011   8215250  1351254****   \n",
       "...               ...         ...         ...       ...          ...   \n",
       "5686   178.140.51.103  1571375258  1571375305  11646500  1755721****   \n",
       "5687     120.27.47.33  1571341423  1571341493    981000  1841007****   \n",
       "5688   65.208.151.115  1571354791  1571354804   2200750  1347045****   \n",
       "5689    39.108.165.98  1571347900  1571347935   1449250  1368294****   \n",
       "5690    112.126.73.56  1571328881  1571328892    239250  1553383****   \n",
       "\n",
       "      goods_id                                         visit_link  \\\n",
       "0        24849  //detail.tmall.com/item.htm?id=532038730419***...   \n",
       "1        14065  //detail.tmall.com/item.htm?id=573659715732***...   \n",
       "2        28803  //detail.tmall.com/item.htm?id=590428245179***...   \n",
       "3        18289  //detail.tmall.com/item.htm?id=17302099374****...   \n",
       "4         7692  //detail.tmall.com/item.htm?id=601449111587***...   \n",
       "...        ...                                                ...   \n",
       "5686      9653  //detail.tmall.com/item.htm?id=561027772418***...   \n",
       "5687      4775  //detail.tmall.com/item.htm?id=586454071825***...   \n",
       "5688      9846  //detail.tmall.com/item.htm?id=570981208552***...   \n",
       "5689     13701  //detail.tmall.com/item.htm?id=520237346984***...   \n",
       "5690     10680  //detail.tmall.com/item.htm?id=600528109589***...   \n",
       "\n",
       "       visit_events source  point_fee  residence_time  \n",
       "0     chargeRequest   淘宝直播        1.9              16  \n",
       "1     chargeRequest   淘宝直播        1.3              30  \n",
       "2     chargeRequest   淘宝直播        1.0              34  \n",
       "3     chargeRequest   淘宝直播        0.6              21  \n",
       "4     chargeRequest    直通车        1.4              30  \n",
       "...             ...    ...        ...             ...  \n",
       "5686         launch   淘宝直播        1.9              47  \n",
       "5687         launch   淘宝直播        0.8              70  \n",
       "5688         launch    直通车        0.4              13  \n",
       "5689         launch   淘宝直播        0.7              35  \n",
       "5690         launch   淘宝直播        1.0              11  \n",
       "\n",
       "[5691 rows x 11 columns]"
      ]
     },
     "execution_count": 358,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "visit_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 369,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>opreate_time</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tpye_operate</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>155</td>\n",
       "      <td>155</td>\n",
       "      <td>155</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              user_id  goods_id  opreate_time\n",
       "tpye_operate                                 \n",
       "0                 155       155           155\n",
       "1                  10        10            10"
      ]
     },
     "execution_count": 369,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "operate_df[operate_df['user_id']==239250].groupby(['tpye_operate']).count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 381,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>tpye_operate</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19500</td>\n",
       "      <td>0</td>\n",
       "      <td>305</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19500</td>\n",
       "      <td>1</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>29750</td>\n",
       "      <td>0</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>38250</td>\n",
       "      <td>0</td>\n",
       "      <td>393</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>38250</td>\n",
       "      <td>1</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1947</th>\n",
       "      <td>12386500</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1948</th>\n",
       "      <td>12388250</td>\n",
       "      <td>0</td>\n",
       "      <td>166</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1949</th>\n",
       "      <td>12388250</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1950</th>\n",
       "      <td>12417500</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1951</th>\n",
       "      <td>12417500</td>\n",
       "      <td>1</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1952 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       user_id  tpye_operate  count\n",
       "0        19500             0    305\n",
       "1        19500             1     10\n",
       "2        29750             0     14\n",
       "3        38250             0    393\n",
       "4        38250             1     10\n",
       "...        ...           ...    ...\n",
       "1947  12386500             2      1\n",
       "1948  12388250             0    166\n",
       "1949  12388250             1      2\n",
       "1950  12417500             0      7\n",
       "1951  12417500             1     26\n",
       "\n",
       "[1952 rows x 3 columns]"
      ]
     },
     "execution_count": 381,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 统计用户在平台的各种操作\n",
    "op_df = user_df.merge(operate_df,left_on=['user_id'],right_on=['user_id'],how='left')\n",
    "op_df = op_df.groupby(['user_id','tpye_operate'])['goods_id'].count().reset_index()\n",
    "op_df.rename(columns={'goods_id':\"count\"},inplace=True)\n",
    "op_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 382,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 持久化\n",
    "op_df.to_sql(\"op_count\",engine,index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 383,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>tpye_operate</th>\n",
       "      <th>opreate_time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>0</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>2</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>2</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>0</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10944750</td>\n",
       "      <td>13451</td>\n",
       "      <td>0</td>\n",
       "      <td>20150604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182875</th>\n",
       "      <td>847750</td>\n",
       "      <td>26631</td>\n",
       "      <td>0</td>\n",
       "      <td>20150730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182876</th>\n",
       "      <td>847750</td>\n",
       "      <td>26631</td>\n",
       "      <td>0</td>\n",
       "      <td>20150730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182877</th>\n",
       "      <td>847750</td>\n",
       "      <td>2845</td>\n",
       "      <td>0</td>\n",
       "      <td>20150812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182878</th>\n",
       "      <td>847750</td>\n",
       "      <td>5317</td>\n",
       "      <td>0</td>\n",
       "      <td>20150808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>182879</th>\n",
       "      <td>847750</td>\n",
       "      <td>22353</td>\n",
       "      <td>0</td>\n",
       "      <td>20150808</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>182880 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         user_id  goods_id  tpye_operate  opreate_time\n",
       "0       10944750     13451             0      20150604\n",
       "1       10944750     13451             2      20150604\n",
       "2       10944750     13451             2      20150604\n",
       "3       10944750     13451             0      20150604\n",
       "4       10944750     13451             0      20150604\n",
       "...          ...       ...           ...           ...\n",
       "182875    847750     26631             0      20150730\n",
       "182876    847750     26631             0      20150730\n",
       "182877    847750      2845             0      20150812\n",
       "182878    847750      5317             0      20150808\n",
       "182879    847750     22353             0      20150808\n",
       "\n",
       "[182880 rows x 4 columns]"
      ]
     },
     "execution_count": 383,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "operate_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 387,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>category</th>\n",
       "      <th>visit_time</th>\n",
       "      <th>two_time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19500</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>1571399151</td>\n",
       "      <td>1571399167</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19500</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>1571388544</td>\n",
       "      <td>1571388578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>29750</td>\n",
       "      <td>信息安全</td>\n",
       "      <td>1571406878</td>\n",
       "      <td>1571406901</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>38250</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>1571406379</td>\n",
       "      <td>1571406431</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39750</td>\n",
       "      <td>计算机考试</td>\n",
       "      <td>1571404898</td>\n",
       "      <td>1571404962</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5686</th>\n",
       "      <td>12386500</td>\n",
       "      <td>数据库</td>\n",
       "      <td>1571347344</td>\n",
       "      <td>1571347385</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5687</th>\n",
       "      <td>12388250</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>1571409473</td>\n",
       "      <td>1571409547</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5688</th>\n",
       "      <td>12388250</td>\n",
       "      <td>计算机考试</td>\n",
       "      <td>1571391918</td>\n",
       "      <td>1571391946</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5689</th>\n",
       "      <td>12417500</td>\n",
       "      <td>数据库</td>\n",
       "      <td>1571334021</td>\n",
       "      <td>1571334099</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5690</th>\n",
       "      <td>12417500</td>\n",
       "      <td>网络与数据通信</td>\n",
       "      <td>1571395273</td>\n",
       "      <td>1571395320</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5691 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       user_id category  visit_time    two_time\n",
       "0        19500     程序设计  1571399151  1571399167\n",
       "1        19500     人工智能  1571388544  1571388578\n",
       "2        29750     信息安全  1571406878  1571406901\n",
       "3        38250     程序设计  1571406379  1571406431\n",
       "4        39750    计算机考试  1571404898  1571404962\n",
       "...        ...      ...         ...         ...\n",
       "5686  12386500      数据库  1571347344  1571347385\n",
       "5687  12388250     程序设计  1571409473  1571409547\n",
       "5688  12388250    计算机考试  1571391918  1571391946\n",
       "5689  12417500      数据库  1571334021  1571334099\n",
       "5690  12417500  网络与数据通信  1571395273  1571395320\n",
       "\n",
       "[5691 rows x 4 columns]"
      ]
     },
     "execution_count": 387,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分析用户浏览各个类型商品时长\n",
    "vis_category = user_df.merge(visit_df,left_on=['user_id'],right_on=['user_id'],how='left')\n",
    "vis_category = vis_category.merge(goods_df,left_on=['goods_id'],right_on=['goods_id'],how='left')\n",
    "vis_category = vis_category[['user_id','category','visit_time','two_time']]\n",
    "vis_category"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 391,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>category</th>\n",
       "      <th>stop_time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19500</td>\n",
       "      <td>人工智能</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>19500</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>29750</td>\n",
       "      <td>信息安全</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>38250</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>39750</td>\n",
       "      <td>CAD CAM CAE</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3300</th>\n",
       "      <td>12386500</td>\n",
       "      <td>项目管理 IT人文</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3301</th>\n",
       "      <td>12388250</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3302</th>\n",
       "      <td>12388250</td>\n",
       "      <td>计算机考试</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3303</th>\n",
       "      <td>12417500</td>\n",
       "      <td>数据库</td>\n",
       "      <td>78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3304</th>\n",
       "      <td>12417500</td>\n",
       "      <td>网络与数据通信</td>\n",
       "      <td>47</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3305 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       user_id     category  stop_time\n",
       "0        19500         人工智能         34\n",
       "1        19500         程序设计         16\n",
       "2        29750         信息安全         23\n",
       "3        38250         程序设计         52\n",
       "4        39750  CAD CAM CAE         35\n",
       "...        ...          ...        ...\n",
       "3300  12386500    项目管理 IT人文         70\n",
       "3301  12388250         程序设计         74\n",
       "3302  12388250        计算机考试         28\n",
       "3303  12417500          数据库         78\n",
       "3304  12417500      网络与数据通信         47\n",
       "\n",
       "[3305 rows x 3 columns]"
      ]
     },
     "execution_count": 391,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vis_category['stop_time'] = vis_category['two_time'] - vis_category['visit_time']\n",
    "vis_category = vis_category.groupby(['user_id','category'])['stop_time'].sum().reset_index()\n",
    "vis_category.to_sql(\"vis_category\",engine,index=False)\n",
    "vis_category"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 399,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>reason_frefund</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>19500</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>29750</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>64000</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>140500</td>\n",
       "      <td>拍错/多拍</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>190500</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>266</th>\n",
       "      <td>12234750</td>\n",
       "      <td>材质与商品描述不符</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>267</th>\n",
       "      <td>12239250</td>\n",
       "      <td>拍错/多拍</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>268</th>\n",
       "      <td>12275500</td>\n",
       "      <td>拍错/多拍</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>269</th>\n",
       "      <td>12331000</td>\n",
       "      <td>收到商品破损污渍</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>270</th>\n",
       "      <td>12384250</td>\n",
       "      <td>拍错/多拍</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>271 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      user_id reason_frefund  count\n",
       "0       19500       收到商品破损污渍      1\n",
       "1       29750      材质与商品描述不符      1\n",
       "2       64000      材质与商品描述不符      1\n",
       "3      140500          拍错/多拍      1\n",
       "4      190500       收到商品破损污渍      1\n",
       "..        ...            ...    ...\n",
       "266  12234750      材质与商品描述不符      1\n",
       "267  12239250          拍错/多拍      1\n",
       "268  12275500          拍错/多拍      1\n",
       "269  12331000       收到商品破损污渍      1\n",
       "270  12384250          拍错/多拍      1\n",
       "\n",
       "[271 rows x 3 columns]"
      ]
     },
     "execution_count": 399,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 统计用户退款情况\n",
    "refund_result = user_df.merge(refund_df,left_on=['user_id'],right_on=['user_id'],how='left')\n",
    "refund_result = refund_result.groupby(['user_id','reason_frefund'])['refund_time'].count().reset_index()\n",
    "refund_result.rename(columns={'refund_time':\"count\"},inplace=True)\n",
    "refund_result.to_sql(\"refund_result\",engine,index=False)\n",
    "refund_result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 409,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>category</th>\n",
       "      <th>stop_time</th>\n",
       "      <th>goods_id</th>\n",
       "      <th>goods_name</th>\n",
       "      <th>img_url</th>\n",
       "      <th>goods_url</th>\n",
       "      <th>sales_volume</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>7211250</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>577</td>\n",
       "      <td>16872</td>\n",
       "      <td>Python编程 从入门到实践</td>\n",
       "      <td>http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg</td>\n",
       "      <td>http://product.dangdang.com/24003310.html</td>\n",
       "      <td>149040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2480750</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>532</td>\n",
       "      <td>16872</td>\n",
       "      <td>Python编程 从入门到实践</td>\n",
       "      <td>http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg</td>\n",
       "      <td>http://product.dangdang.com/24003310.html</td>\n",
       "      <td>149040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9202750</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>487</td>\n",
       "      <td>16872</td>\n",
       "      <td>Python编程 从入门到实践</td>\n",
       "      <td>http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg</td>\n",
       "      <td>http://product.dangdang.com/24003310.html</td>\n",
       "      <td>149040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2088000</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>469</td>\n",
       "      <td>16872</td>\n",
       "      <td>Python编程 从入门到实践</td>\n",
       "      <td>http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg</td>\n",
       "      <td>http://product.dangdang.com/24003310.html</td>\n",
       "      <td>149040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7918750</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>439</td>\n",
       "      <td>16872</td>\n",
       "      <td>Python编程 从入门到实践</td>\n",
       "      <td>http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg</td>\n",
       "      <td>http://product.dangdang.com/24003310.html</td>\n",
       "      <td>149040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>879</th>\n",
       "      <td>799000</td>\n",
       "      <td>图形图像 多媒体</td>\n",
       "      <td>6</td>\n",
       "      <td>25707</td>\n",
       "      <td>中文版Photoshop 2020完全自学教程</td>\n",
       "      <td>http://img3m4.ddimg.cn/17/34/29001374-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/29001374.html</td>\n",
       "      <td>64081</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>880</th>\n",
       "      <td>3954500</td>\n",
       "      <td>移动开发</td>\n",
       "      <td>6</td>\n",
       "      <td>7376</td>\n",
       "      <td>第一行代码 Android 第2版</td>\n",
       "      <td>http://img3m6.ddimg.cn/46/1/24144166-1_w_30016...</td>\n",
       "      <td>http://product.dangdang.com/24144166.html</td>\n",
       "      <td>14332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>881</th>\n",
       "      <td>1140750</td>\n",
       "      <td>程序设计</td>\n",
       "      <td>6</td>\n",
       "      <td>16872</td>\n",
       "      <td>Python编程 从入门到实践</td>\n",
       "      <td>http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg</td>\n",
       "      <td>http://product.dangdang.com/24003310.html</td>\n",
       "      <td>149040</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>882</th>\n",
       "      <td>7016500</td>\n",
       "      <td>移动开发</td>\n",
       "      <td>6</td>\n",
       "      <td>7376</td>\n",
       "      <td>第一行代码 Android 第2版</td>\n",
       "      <td>http://img3m6.ddimg.cn/46/1/24144166-1_w_30016...</td>\n",
       "      <td>http://product.dangdang.com/24144166.html</td>\n",
       "      <td>14332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>883</th>\n",
       "      <td>8111500</td>\n",
       "      <td>图形图像 多媒体</td>\n",
       "      <td>5</td>\n",
       "      <td>25707</td>\n",
       "      <td>中文版Photoshop 2020完全自学教程</td>\n",
       "      <td>http://img3m4.ddimg.cn/17/34/29001374-1_w_2.jpg</td>\n",
       "      <td>http://product.dangdang.com/29001374.html</td>\n",
       "      <td>64081</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>884 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     user_id  category  stop_time  goods_id               goods_name  \\\n",
       "0    7211250      程序设计        577     16872          Python编程 从入门到实践   \n",
       "1    2480750      程序设计        532     16872          Python编程 从入门到实践   \n",
       "2    9202750      程序设计        487     16872          Python编程 从入门到实践   \n",
       "3    2088000      程序设计        469     16872          Python编程 从入门到实践   \n",
       "4    7918750      程序设计        439     16872          Python编程 从入门到实践   \n",
       "..       ...       ...        ...       ...                      ...   \n",
       "879   799000  图形图像 多媒体          6     25707  中文版Photoshop 2020完全自学教程   \n",
       "880  3954500      移动开发          6      7376        第一行代码 Android 第2版   \n",
       "881  1140750      程序设计          6     16872          Python编程 从入门到实践   \n",
       "882  7016500      移动开发          6      7376        第一行代码 Android 第2版   \n",
       "883  8111500  图形图像 多媒体          5     25707  中文版Photoshop 2020完全自学教程   \n",
       "\n",
       "                                               img_url  \\\n",
       "0       http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg   \n",
       "1       http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg   \n",
       "2       http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg   \n",
       "3       http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg   \n",
       "4       http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg   \n",
       "..                                                 ...   \n",
       "879    http://img3m4.ddimg.cn/17/34/29001374-1_w_2.jpg   \n",
       "880  http://img3m6.ddimg.cn/46/1/24144166-1_w_30016...   \n",
       "881     http://img3m0.ddimg.cn/67/4/24003310-1_w_7.jpg   \n",
       "882  http://img3m6.ddimg.cn/46/1/24144166-1_w_30016...   \n",
       "883    http://img3m4.ddimg.cn/17/34/29001374-1_w_2.jpg   \n",
       "\n",
       "                                     goods_url  sales_volume  \n",
       "0    http://product.dangdang.com/24003310.html        149040  \n",
       "1    http://product.dangdang.com/24003310.html        149040  \n",
       "2    http://product.dangdang.com/24003310.html        149040  \n",
       "3    http://product.dangdang.com/24003310.html        149040  \n",
       "4    http://product.dangdang.com/24003310.html        149040  \n",
       "..                                         ...           ...  \n",
       "879  http://product.dangdang.com/29001374.html         64081  \n",
       "880  http://product.dangdang.com/24144166.html         14332  \n",
       "881  http://product.dangdang.com/24003310.html        149040  \n",
       "882  http://product.dangdang.com/24144166.html         14332  \n",
       "883  http://product.dangdang.com/29001374.html         64081  \n",
       "\n",
       "[884 rows x 8 columns]"
      ]
     },
     "execution_count": 409,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据浏览情况 猜测用户可能喜欢的商品\n",
    "goods_df_temp = goods_df.sort_values(by=['sales_volume'],ascending=False)\n",
    "goods_df_temp = goods_df_temp.drop_duplicates(subset='category',keep='first')\n",
    "goods_df_temp = goods_df_temp[['goods_id','goods_name','img_url','goods_url','category','sales_volume']]\n",
    "recommend_df = vis_category.sort_values(by=['stop_time'],ascending=False)\n",
    "recommend_df = recommend_df.drop_duplicates(subset='user_id',keep='first')\n",
    "recommend_df = recommend_df.merge(goods_df_temp,left_on=['category'],right_on=['category'],how='left')\n",
    "recommend_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 410,
   "metadata": {},
   "outputs": [],
   "source": [
    "recommend_df.to_sql(\"recommend_df\",engine,index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
